On this page you will find log4j tutorial, Log4j is a java api used for logging messages which can be helpful later on could be while debugging or any other purpose.

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.

Logging does have its drawbacks also. It can slow down an application. If too verbose, it can cause scrolling blindness. To alleviate these concerns, log4j is designed to be reliable, fast and extensible.

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 –

Why do we need logging in Java / Selenium?
Why Log4j is better than System.Out.Println? (What is difference between log4j and common loggings?)
What are the main components in Log4j?
How to Configure Log4j in your project (Using Log4j.properties file)?
How to Configure Log4j in your project (Using Log4j.xml file)?
What are different logging levels in Log4j?
Can Logging in Java affect the performance of the application?

Looking for learning Framework Development from Scratch? Lookout for Detailed Framework Development videos on YouTube here -


Get the Framework code at Github Repo: https://github.com/prakashnarkhede?tab=repositories