Log4j Architecture

In this tutorial we will see about log4j architecture. Already I mentioned there are two types of objects available in log4j in Log4J Introduction. We will see in detail now.

1.Core Objects – These are mandatory required object to use log4j framework

2.Support Objects – These are optional objects which give support to core object.

Log4J Core Objects

1.Logger

This is most important component of log4j.It is responsible for capture the logging information.Logger contains following levels.

Debug

Useful for debug an application

Info

Provides informational messages

Warn

Provide the details of harmful events

Error

It provide the error and exception thrown in application and allow the application continue its execution

Fatal

It provides the details severe error events like application may leads to abort

ALL

Used to turn on all logging level.

OFF

It is used to turn off all logging level

2. Appenders in log4

The Appender is responsible to publish log messages in desired destination. Log4j provides following appenders.

  1. Console Appender
  2. DailyRollingFileAppender
  3. FileAppender
  4. RollingFileAppender
  5. WriterAppender
  6. SMTPAppender
  7. WriterAppender
  8. SocketAppender
  9. SocketHubAppender
  10. SyslogAppender
  11. JDBCAppender
  12. TelnetAppender
  13. AppenderSkeleton
  14. AsyncAppender
  15. ExternallyRollingFileAppender
  16. JMSAppender
  17. LF5Appender
  18. NTEventLogAppender
  19. NullAppender

We will see the appenders in detail with examples.

3. Layouts in log4j

Layout is responsible for how to format layout.Types of log4j layouts are given below

1.HTMLLayout – It format output in table formatted output in html file.

2.PatternLayout – It format the output in given conversion pattern with all supported appenders

3.SimpleLayout – It provide simple formatted output. It output will be log level followed by log message

4.XMLLayout – Its provide the xml formatted output

Log4J Supported Objects

Level Objects

The level objects defines the priority to logging.Here I listed the levels in their priority

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

We Will see these levels in details in upcoming chapters.

Log4J FILTER

Filter is object applied on logger and make further decision on whether information should be logged or not

Log4J ObjectsRenderer

The object renderer objects provides the string representation of different objects passed to log4j framework.this object used by layout to prepare final logging information

Log4J Logmanager

The LogManager is responsible for reading configuration information from confiuration file or class


Ask your questions in eHowToNow Forum

Post your technical, non-technical doubts, questions in our site. Get answer as soon as possible, meanwhile you can help others by answering, unanswered questions.
To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

  1. Log4j Architecture
  2. Log4j Introduction
  3. Log4j Example using XML configuration
  4. Log4j Basic Configurator Example
  5. Log4j Example using Property File

Be the first to comment

Leave a Reply

Your email address will not be published.


*