Tuesday, February 19, 2013

Using Log4Net Appenders at different levels


<log4net>
  <appender name="SomeXmlAppender" type="log4net.Appender.RollingFileAppender">
    <pattern ... />
    <evaluator type="log4net.Core.LevelEvaluator">
      <threshold value="INFO"/>
    </evaluator>
    <filter type="log4net.Filter.LevelRangeFilter">
      <levelMin value="INFO" />
      <acceptOnMatch value="true" />
    </filter>
    <filter type="log4net.Filter.DenyAllFilter" />
  </appender>

  <appender name="SomeEventLogAppender" type="log4net.Appender.EventLogAppender">
    <pattern ... />
    <evaluator type="log4net.Core.LevelEvaluator">
      <threshold value="ERROR"/>
    </evaluator>
    <filter type="log4net.Filter.LevelRangeFilter">
      <levelMin value="ERROR" />
      <acceptOnMatch value="true" />
    </filter>
    <filter type="log4net.Filter.DenyAllFilter" />
  </appender>

  <root>
    <level value="DEBUG" />
    <appender-ref ref="SomeXmlAppender" />
    <appender-ref ref="SomeEventLogAppender" />
  </root>
</log4net>

No comments:

Post a Comment