Log specific level with log4net

  • Thread starter Thread starter peterbf
  • Start date Start date
P

peterbf

Hello

I am using log4net in an application. I would like to log with some
specific levels, but I am not sure if it is possibel.
For instance I would like to log ERROR, FATAL and INFO, but not WARN.
The reason is that I would like tol log performance with INFO, but I
do not want to log warnings.

Is this possible?

Peter Frederiksen
 
I am using log4net in an application. I would like to log with some
specific levels, but I am not sure if it is possibel.
For instance I would like to log ERROR, FATAL and INFO, but not WARN.
The reason is that I would like tol log performance with INFO, but I
do not want to log warnings.

Is this possible?

I don't *believe* it's possible, no. But the way round this (which is
more flexible, IMO) is to use a different log category for
performance. Then you can control that completely independently.

Jon
 
Thanks for the suggestion.

I ended up using af filter which is an OK solution for me:
<log4net>
<appender name="SCLogAppender"
type="CSC.SC.Enterprise.Log4NetUtils.SCLogAppender, Log4NetUtils2">
<filter type="log4net.Filter.LevelMatchFilter">
<acceptOnMatch value="false" />
<levelToMatch value="WARN" />
</filter>
</appender>
<root>
<level value="INFO" />
<appender-ref ref="SCLogAppender" />
</root>

</log4net>

Peter Bøtker Frederiksen
 
Back
Top