log4j 介绍(3)--Appender 篇

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……
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值