We are moved to new domain
Click -> www.ehowtonow.com
Thursday, 15 August 2013

log4j - Architecture


In this tutorial we will see about log4j architecture.Already I mentioned there are two types of objects available in log4j.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.

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 lig4j

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

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.

FILTER

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

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

Logmanager

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


Shop and help us

Flipkart Offer Snapdeal offer Amazon.in offer Amazon.com offer
  • Blogger Comments
  • Facebook Comments
  • Disqus Comments

0 comments:

Post a Comment

Item Reviewed: log4j - Architecture Rating: 5 Reviewed By: eHowToNow