Which is best for getting the log files of user logged in his account? Explain with a small example... Thanks for your time...
Java Util Logging performance is significantly affected by the lack of a buffered handler. There is no major difference between Log4j and Logback. Both Log4j and Logback show about 50% of the performance of my special case optimized strawman.
Logging in simple words refers to the recording of an application activity. Logging is used to store exceptions, information, and warnings as messages that occur during the execution of a program. Logging helps a programmer in the debugging process of a program. Java provides logging facility in the java. util.
One of the most popular solutions for the Java world is the Apache Log4j 2 framework. Maintained by the Apache Foundation, Log4j 2 is an improvement on the original Log4j, which was the most popular logging framework in Java for many years.
Log4j is a defacto standard logging library for Java.
Java.util.logging is a built in logging mechanism in Java, but that doesn't make it the greatest...
Use Log4j and its MDC. This way, you can easily log different user accounts like this:
MDC.put(user);
logger.log("Deleted something important!");
This way, if logging is configured correctly, in your log output you will see something like this:
[user Alice] Deleted something important!
and this will work for every user in a multi user environment.
Note: if you're starting a new project, I'd suggest using slf4j and Logback. This combination is even more powerful than log4j or java.util.logging.
I have been using this combination for some time and it has really paid off handsomely. Very useful for bug squashing and auditing user interaction, among other things.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With