Logging equips the developer with detailed context for application failures. On the other hand, testing provides quality assurance and confidence in the application. Logging and testing should not be confused. They are complementary. When logging is wisely used, it can prove to be an essential tool.
To add to this, with Log4J you can dynamically switch logging on/off. You can change the format dynamically (do you want timestamps ? datestamps ?) and you can change where the logging goes (to the console ? to a file ? to a database ?), all without changing your code.
You can also log to multiple sources at once. In an application I'm working on now, when I'm testing the application, I log to both the console (so I can see debug information as well as any errors that pop up) along with the standard log file that's always logged to. Quite handy
The beauty of log4j is in its architecture of appenders and layouts. As mentioned by previous poster, you change the aspect of logging of your application without much hassle, most of the time it's just a matter of simple configuration. One of the usages I would add on my part is centralized logging which can be added to your application without touching its code base
http://www.tutorialspoint.com/log4j/log4j_sample_program.htm
ReplyDelete