Q: 什么是Appender?
A: Log4j allows logging requests to print to multiple destinations. In log4j speak, an output destination is called an appender.
Q: 目前有几多类型的Appender?
A: Currently, appenders exist for the console, files, GUI components, remote socket servers, JMS, NT Event Loggers, and remote UNIX Syslog daemons. It is also possible to log asynchronously.
Q:一个logger是不是只能对应一类Appender?
A: More than one appender can be attached to a logger.
Q: 如何让一个logger能够对应几个Appenders?
A: The addAppender method adds an appender to a given logger.
[color=darkred][b]
Appender Additivity [/b][/color]
The output of a log statement of logger C will go to all the appenders in C and its ancestors. This is the meaning of the term "appender additivity".
However, if an ancestor of logger C, say P, has the additivity flag set to false, then C's output will be directed to all the appenders in C and it's ancestors upto and including P but not the appenders in any of the ancestors of P.
这段话的意思是:有一个logger C,C的Appenders是其自身和ancestors的Appenders的总和,相当于累加了。然而,如果logger P 作为 C 的ancestor,P的additivity flag设定为false,那么C的Appenders只能向上累加到 P ancestor为止, P上面的ancestor 的 Appender不会被累加到。
Loggers have their additivity flag set to true by default.
点击查看清晰例子:
[img]/upload/attachment/137365/97323bc9-2e61-32c7-969b-6da1c179d8ea.bmp[/img]
Move on……
A: Log4j allows logging requests to print to multiple destinations. In log4j speak, an output destination is called an appender.
Q: 目前有几多类型的Appender?
A: Currently, appenders exist for the console, files, GUI components, remote socket servers, JMS, NT Event Loggers, and remote UNIX Syslog daemons. It is also possible to log asynchronously.
Q:一个logger是不是只能对应一类Appender?
A: More than one appender can be attached to a logger.
Q: 如何让一个logger能够对应几个Appenders?
A: The addAppender method adds an appender to a given logger.
[color=darkred][b]
Appender Additivity [/b][/color]
The output of a log statement of logger C will go to all the appenders in C and its ancestors. This is the meaning of the term "appender additivity".
However, if an ancestor of logger C, say P, has the additivity flag set to false, then C's output will be directed to all the appenders in C and it's ancestors upto and including P but not the appenders in any of the ancestors of P.
这段话的意思是:有一个logger C,C的Appenders是其自身和ancestors的Appenders的总和,相当于累加了。然而,如果logger P 作为 C 的ancestor,P的additivity flag设定为false,那么C的Appenders只能向上累加到 P ancestor为止, P上面的ancestor 的 Appender不会被累加到。
Loggers have their additivity flag set to true by default.
点击查看清晰例子:
[img]/upload/attachment/137365/97323bc9-2e61-32c7-969b-6da1c179d8ea.bmp[/img]
Move on……