开发者

Difference between logger and root level in log4Net?

I just came across the two sections in log4net configiurations:

<logger name="File">
  <开发者_JAVA技巧level value="All" />
</logger>
<root>
  <level value="INFO" />
</root>

May I know what is the difference of specifying levels at logger and root tags? What is the difference between them?


root means all logs in the application, and logger allows to refer to a certain kind of log. Using them you can change the log configuration only for cetain logs. Look your sample with comments:

<!-- Set root logger level to INFO-->
<root>
    <level value="INFO" />
</root>

<!-- Print only messages of level WARN or above in the package "File" -->
<logger name="File">
    <level value="WARN" />
</logger>

In this sample all logs are to INFO, and the the log of the type "File" (or named File) is WARN.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜