首页 > 代码库 > Understanding Apache Log4j

Understanding Apache Log4j

Overview of the log4j architecture:

The architecture of the log4j API is layerd. Each layer consist of different objects performing different task. 

The Top layer captures the logging information

The middle layer is involved in analyzing and authorizing the logging information

The bottom layer is responsible for formating and publishing the logging information

In essence, log4j consist of three types of primary objects:

  • Logger : is responsible for capturing the logging information
  • Appender: logging information to various prefered destinations
  • Layout: is used to format information in different styles.

Apart form them, there are several auxiliary objects that can plug and play to any layer of the API:

  • Level: there are seven levels of logging defiend within the Api:OFF,DEBUG,INFO,ERROR,WARN,FATAL and ALL.
  • Filter: is used to analyze logging information and make further decisions on wheter  that information should be logged or not
  • ObjectRender: is specialized in providing a String representation of differetn objects passed to the logging framwork.
  • LogManager: is responsible for reading and initial configuration parameters from a system-wide configuration file or a configuration class

it‘s time to discuss how they interact with each other:

Understanding Apache Log4j