Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of Log4j API?

Tags:

log4j

I am going to use Log4j in my web application and I am new to that. What is the uses of Log4j and how I use it in my application. Thanks in advance.

like image 249
i2ijeya Avatar asked Sep 29 '09 12:09

i2ijeya


1 Answers

I think the Log4J home page offers the best overview and rationale behind its use.

With log4j it is possible to enable logging at runtime without modifying the application binary. The log4j package is designed so that these statements can remain in shipped code without incurring a heavy performance cost. Logging behavior can be controlled by editing a configuration file, without touching the application binary.

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.

like image 79
Brian Agnew Avatar answered Sep 28 '22 17:09

Brian Agnew