log4net filtering

R

rosshinkley

Greetings.

I know that log4net supports filtering based on properties
(log4net.Filter.PropertyFilter). Trouble is, I'm having trouble
spotting what valid property names are. Are they intrinsic to log4net
or are they defined by the appender/logger itself?

I would like to filter on a method name, for example, instead of the
message itself. PropertyFilter looks promising because MDCFilter and
NDCFilter are supposedly deprecated in favor of PropertyFilter
(according the the log4net documentation).

Any suggestions?

An appender that should get my question across is pasted below.

-Ross

<appender name="RollingFile"
type="log4net.Appender.RollingFileAppender" >
<!-- Set up the log file name prefix -->
<file value="log" />
<!-- Append to the end of the file. -->
<appendToFile value="true" />
<!-- Roll by date (as opposed to size) -->
<rollingStyle value="Date" />
<!-- Date pattern to use for the file suffix -->
<datePattern value="yyyyMMdd" />
<!-- Layout for the file messages -->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger
[%property{NDC}] - %message%newline" />
</layout>
<!-- ignore MyMethod messages.-->
<filter type="log4net.Filter.PropertyFilter">
<key value="MethodName"/>
<stringToMatch value="MyMethod"/>
<acceptOnMatch value="false"/>
</filter>
</appender>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top