19

I just came across the two sections in log4net configiurations:

<logger name="File">
  <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?

Philipp M
  • 1,877
  • 7
  • 27
  • 38
Rocky Singh
  • 15,128
  • 29
  • 99
  • 146

1 Answers1

10

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.

Philipp M
  • 1,877
  • 7
  • 27
  • 38
Daniel Peñalba
  • 30,507
  • 32
  • 137
  • 219