Log4j Architecture

Log4j Architecture
Screenshot from 2020 01 14 17 10 15

Log4j Arch contains mainly the following Objects

  1. Logger
  2. Appender
  3. Layout
  4. Level
  5. LogManager
  6. Filter
  7. ObjectRender
1. Logger

This Object is responsible to get logging messages from Java applications.

2. Appender

The main intention of Appender object is to get logging messages from Logger object and publishing that logging messages to the preferred destinations. Each and Every Appender Object must have at least one Destination object in order to send logging messages.


ConsoleAppender is able to store logging messages on Console.

3. Layout

The main intention of Layout object is to format logging messages in different styles. Layout Object is used by Appender object just before publishing Logging Messages.

4. Level

The main intention of Level object is to define granularity and priority of any Logging information. Each and every Logging information must be with a particular Logging Level. Log4j API has provided the following Levels to the Logging messages.

  1. ALL
  2. TRACE
  3. DEBUG
  4. INFO
  5. WARN
  6. ERROR
  7. FATAL
  8. OFF

Log4j is giving priorities for the logging messages in the following order.

6. LogManager

LogManager is the central component , it able to manage Log4j framework, it will read all the initial configuration details from the configuration file and stored the Logger objects in namespace hierarchy with a particular reference name for future reference.

If our application access any Logger object on the basis of the reference name then LogManager will return the existed Logger object otherwise it will create new Logger object and return to the application.

7. Filter

The main intention of Filter object is used to analyze logging information and takes the decision whether the messages must be logged or not. An Appender object may have no of Filter objects, they must approve our logging message before publishing logging messages in destination.

8. ObjectRender

This Object will be used by Layout object in order to get string representation of the several objects which are passed through Log4j framework

Log4j Architecture
Scroll to top