Log4j official document translation (II architecture design)

log4j follow the hierarchical structure, each layer has a different object to perform different tasks. This structure, then the level of design flexibility and easy future expansion.

log4j frame has two objects:

  • Core objects: an object supporting framework, the framework is an essential component.
  • Support objects: These are optional object frame, used to provide additional important work.


Core objects include the following types:

  1. logger objects , is the highest layer, is responsible for transforming logs by using different styles. It provides information to target appender before release. (Layer herein refers to a position located)
  2. The layout object , for providing formatting style log information, the log information before release, to make it readable, reusable.
  3. appender objects , the objects belonging to the bottom of the object, which is responsible for publishing the information to different destinations, such as databases, files, console, UNIXsyslog and so on.


Here is the log4j architecture composition diagram:



Support objects, they played a crucial role in log4j framework:

  1. level objects : object definition to the log level and size of the priority information, there are seven levels: OFF, DEBUG, INFO, ERROR , WARN, FATAL and ALL.
  2. Filter object : the log information for analyzing the log information and decide whether to output. Each appender object can have several filters objects work together, when the log information to reach specific appender, all filters will help appender function filtering operation prior to its release to the destination.
  3. Object Renderer : providing a string for transmitting the log to identify different objects, the object information is also used to prepare the layout objects constant.
  4. Log Manager : to manage logging framework, which is responsible for reading information from the initial configuration, this configuration may be the configuration file, it may be configured class.

Reproduced in: https: //my.oschina.net/u/204616/blog/545136

Guess you like

Origin blog.csdn.net/weixin_33978044/article/details/91989590