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.
- Console Appender
- DailyRollingFileAppender
- FileAppender
- RollingFileAppender
- WriterAppender
- SMTPAppender
- WriterAppender
- SocketAppender
- SocketHubAppender
- SyslogAppender
- JDBCAppender
- TelnetAppender
- AppenderSkeleton
- AsyncAppender
- ExternallyRollingFileAppender
- JMSAppender
- LF5Appender
- NTEventLogAppender
- 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
- ALL
- TRACE
- DEBUG
- INFO
- WARN
- ERROR
- FATAL
- 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
0 comments:
Post a Comment