Configuration question: Log only in child, but not in parent?
I have got following configuration:
<log4net>
<!--<appenders />-->
<root />
<logger name="MyProject">
<priority value="INFO" />
<appender-ref ref="rollingProjectFile" />
</logger>
<logger name="MyProject.Jobs">
<priority value="INFO" />
<appender-ref ref="rollingJobsFile" />
</logger>
</log4net>
Both appenders within the two different loggers write to a text-file. Since I would like to have a different text开发者_C百科-file for the namespace MyProject.Jobs
, I defined the second logger. But additionally the same messages are also logged within the parent-logger MyProject
. How can I achieve a complete separation if I don't want any messages from the child-logger to appear in the parent-logger?
Thx for any tipps sl3dg3
You might try:
<logger name="MyProject.Jobs" additivity="false">
...
I think you can apply a section to the logger to filter out the child logger. Though there may be an easier way to accomplish this.
<filter type="log4net.Filter.LoggerMatchFilter">
<loggerToMatch value="MyProject.Jobs" />
<acceptOnMatch value="false" />
</filter>
精彩评论