Log4Net configuring log level

Dan picture Dan · Aug 8, 2008 · Viewed 105.3k times · Source

How do I make Log4net only log Info level logs? Is that even possible? Can you only set a threshold?

This is what I have, and it logs Info and above as I would expect. Is there anything i can do to make it only log info?

<logger name="BrokerCollection.Model.XmlDocumentCreationTask">
  <appender-ref ref="SubmissionAppender"/>
  <level value="Info" />
</logger>

Answer

Brandon Wood picture Brandon Wood · Aug 13, 2008

Within the definition of the appender, I believe you can do something like this:

<appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
    <filter type="log4net.Filter.LevelRangeFilter">
        <param name="LevelMin" value="INFO"/>
        <param name="LevelMax" value="INFO"/>
    </filter>
    ...
</appender>