Log4j Architecture
Log4j Arch contains mainly the following Objects
- Logger
- Appender
- Layout
- Level
- LogManager
- Filter
- 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.
E.g
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.
- ALL
- TRACE
- DEBUG
- INFO
- WARN
- ERROR
- FATAL
- OFF
Log4j is giving priorities for the logging messages in the following order.
ALL >TRACE > DEBUGG > INFO > WARN > ERROR > FATAL>OFF
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