Log 4 jまとめ(三)log 4 jのLogger

1714 ワード

Loggers are named entities. Logger names are case-sensitive and they follow the hierarchical naming rule:
Named Hierarchy
A logger is said to be an
ancestor of another logger if its name followed by a dot is a prefix of the
descendant logger name. A logger is said to be a
parent of a
child logger if there are no ancestors between itself and the descendant logger.
For example, the logger named "com.foo" is a parent of the logger named "com.foo.Bar" . Similarly, "java" is a parent of "java.util" and an ancestor of "java.util.Vector" . This naming scheme should be familiar to most developers.
The root logger resides at the top of the logger hierarchy. It is exceptional in two ways:
  • it always exists,
  • it cannot be retrieved by name.

  • This observation had previously led us to choose category as the central concept of the package. However, since log4j version 1.2, Logger class has replaced the Category class.
     
    log 4 jのLoggerは大文字小文字に敏感であり、名称継承規則に従う.
    名前継承規則は次のとおりです.
    Javaのようなpackage.「com.foo」が「com.foo.Bar」の親であり、「com.foo.Bar.aeo」の祖先であり、この継承関係において「com.foo.Bar」がロガーでなければ、「com.foo」は直接「com.foo.Bar.aeo」の親である.log 4 jのトップクラスの親はroot.
    rootは永遠に存在し、名前で取得できません.子は親の設定を継承します.
     
    log 4 jは1.2以降、「Logger」の代わりに「Category」をLoggerのrootとして使用している.
    Logger root = Logger.getRootLogger();
    

    ロガーのレベルは
    TRACE,DEBUG,INFO,WARN,ERROR,FATAL