Log4j is the standard defacto logging library for Java.
Java.util.logging is the built-in logging mechanism in Java, but that does not make it the biggest ...
Use Log4j and its MDC . Thus, you can easily register various user accounts as follows:
MDC.put(user); logger.log("Deleted something important!");
Thus, if logging is configured correctly, you will see something like this in the log output:
[user Alice] Deleted something important!
and this will work for each user in a multi-user environment.
Note: if you are starting a new project, I would suggest using slf4j and Logback . This combination is even more powerful than log4j or java.util.logging.
I used this combination for some time, and it really paid off beautifully. Very useful for noise reduction and auditing user interactions, among other things.
darioo
source share