What is Log4J. An absolute beginners tutorial.

What is Apache Log4J

Log4j is a Reliable, Flexible and Fast Logging Framework (APIs) written in Java which is distributed by Apache Software License.

Log4j can be used with C++,C#,Perl,C,Python,Eiffel and Ruby languages.

Log4j can be configured through external configuration file at runtime. It is logging process in terms of levels

Three main components of Log4j:

  • Loggers:To capture logging information
  • Appenders:It can publish logging information to various destinations.
  • Layouts:It can different style format logging information.

History of log4j

  • It is an API developed in 1996 by E.U.SEMPER
  • It is an open source API which is distributed by Apache Software License.
  • The class files, full source code, documentation and latest log4j version can be found in

log4j Features

  • log4j support thread safe.
  • Speed is optimized in log4j
  • Named logging hierarchy supported in log4j
  • Multiple output supported in log4j
  • Internationalization supported by log4j.
  • Runtime configuration of logging behavior
  • Exception is handled by log4j
  • TRACE,ALL, INFO, WARN, DEBUG, ERROR and FATAL are the levels of log4j
  • Log output format can be easily changed by layout class extending.
  • Appender interface allows altering target out along with writing strategy.

Pros N Cons of Logging:

Logging is core component of software development. Logging helps in easy maintenance, quick debugging of the application runtime information.

Main drawback of logging is it slow’s down the application. Log4j is designed to fast, extensible and reliable.


This tutorial is aimed at learners who want to get an understaind on what Log4J is and what it is used for. This tutorial have 10 part to it as shown below

  1. Overview    
  2. How to Install Log4J
  3. Understanding Architecture
  4. Getting started with Log4J Configuration
  5. Sample Program
  6. Logging Methods
  7. Understanding different Logging Levels
  8. Log4J log formatting
  9. How to log in files
  10. How to log in database using Log4J

We hope that this tutorial will help you out with Log4J. Please note that this tutorial is for absolute starters and does not go into much depth. Let us know how we can improve by sending  your feedback.


A good understanding of Java programming language is required.


Absolute beginners

Author: Subject Coach
Added on: 7th Mar 2015

You must be logged in as Student to ask a Question.

None just yet!