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
This is most important component of log4j.It is responsible for capture the logging information.Logger contains following levels.
Useful for debug an application
Provides informational messages
Provide the details of harmful events
It provide the error and exception thrown in application and allow the application continue its execution
It provides the details severe error events like application may leads to abort
Used to turn on all logging level.
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
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
The level objects defines the priority to logging.Here I listed the levels in their priority
We Will see these levels in details in upcoming chapters.
Filter is object applied on logger and make further decision on whether information should be logged or not
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
The LogManager is responsible for reading configuration information from confiuration file or class