471,330 Members | 1,808 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

log4net filtering


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.


<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" />
<!-- ignore MyMethod messages.-->
<filter type="log4net.Filter.PropertyFilter">
<key value="MethodName"/>
<stringToMatch value="MyMethod"/>
<acceptOnMatch value="false"/>
Jun 27 '08 #1
0 1262

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by SK | last post: by
reply views Thread by anonieko | last post: by
reply views Thread by Joneleth | last post: by
4 posts views Thread by Gawel | last post: by
2 posts views Thread by Vikram | last post: by
2 posts views Thread by Marc Scheuner | last post: by
2 posts views Thread by forest demon | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.