开发者

Difference between logger and root level in log4Net?

开发者 https://www.devze.com 2023-02-02 02:53 出处:网络
I just came across the two sections in log4net configiurations: <logger name=\"File\"> <开发者_JAVA技巧level value=\"All\" />

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

精彩评论

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