Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 1.29 KB

log4j2.md

File metadata and controls

18 lines (11 loc) · 1.29 KB

log4j2 学习笔记

log4j2 体系结构

Applications using the Log4j 2 API will request a Logger with a specific name from the LogManager. The LogManager will locate the appropriate LoggerContext and then obtain the Logger from it. If the Logger must be created it will be associated with the LoggerConfig that contains either a) the same name as the Logger, b) the name of a parent package, or c) the root LoggerConfig.LoggerConfig objects are created from Logger declarations in the configuration. -- log4j2 体系结构(官方版)

  • 配置文件中, 每定义一个 logger 就定义了一个 LoggerConfig
  • 后期通过 LogManager.getLogger() 来获取 logger 时, 新的 logger 会直接关联到相应的 LoggerConfig 上。

参考

  1. log4j2 体系结构(官方版)
  2. Log4j2 架构及概念简介
  3. Log4j 2使用教程, 写的很不错。推荐一下。
  4. PatternLayout。用来规定输出格式的详细文档。