My problem is with registering library classes (classes that are used inside libraries). Currently we use log4cxx , but the log4j library implements the same concepts.
Let's say I have a process that has several entities, A, B, and C. Each of them uses many different classes and functions, clearly separated in the code.
A, B and C use many classes, functions, objects, resources, and sometimes global variables (outdated code, I can not do anything about it ...) - let's call them all foo
Writing A, B, and C turned out to be a performance issue, the log exploded when we set the log level for debugging. After viewing our system, we came to the following conclusions:
- We want to be able to change the debugging level for only one of the classes at a time (or all of them using root)
- When all kinds of
foo are printed to the log, we need to see which object named it, A, B or C. - Since there are many
foo , we want to be able to change the debug level separately for each foo - A
foo should be considered as a shared library; it cannot directly depend on A, B or C. - A, B and C can use the same instance of
foo (for example, the same instance of our resource handling class is used by A, B and C), in the log we would like to see which class was used by foo . - A can use B (or C), but we should not see it in the log ...
This is what we have come up with so far -
A, B and C will have separate registrars. A global variable (stored in another library with all our helpers and journal wrappers) will always keep current journal reporting. Each time an object begins to process it logically, it sets a global variable to the corresponding registrar. When foo wants to report to the log, it reports through a global variable and adds its name (and context) to the log message .
The problem is that there seems to be something that does this already, the solution doesn't feel clean, having such a global variable ...
Are we doing something wrong? Is there a better solution for this?
java c ++ logging log4j log4cxx
user1708860
source share