Log4j (Log for Java) is logging framework provided by apache foundation for java based applications.
In the applications, if you want to log some information, like any event triggered, or any Database updated is happened, we have the need to log the specific information or error for the useful of the application.
To debug any issues in applications, we have to log the error/exceptions in the logs. For this we will use log4j mechanism.
Log4j logs the information and shows this information in different targets. The different targets are called appenders (console, file etc ).
Log4J is a java library that enables you to put the equivalent of a “println” statement all over your code, with “levels” that control whether it shows up in your logs or not.
Logging is an important component of the software development. A well-written logging code offers quick debugging, easy maintenance, and structured storage of an application’s runtime information.
Since logging is rarely the main focus of an application, the log4j API strives to be simple to understand and to use.
What is logging?
> Logging” is producing messages that tell you what your program is doing
> It’s not much different than using System.out.println(…)
> Log messages can go to the console, to a file, or one of several other places
> You can use logging to help you debug a program
> You can use logging to produce a file when the user runs your program
Let us understand more about Log4j with below topics in Log4j tutorial –