log4net filtering

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rosshinkley@gmail.com

    log4net filtering

    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="RollingFi le"
    type="log4net.A ppender.Rolling FileAppender" >
    <!-- 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.L ayout.PatternLa yout">
    <conversionPatt ern value="%date [%thread] %-5level %logger
    [%property{NDC}] - %message%newlin e" />
    </layout>
    <!-- ignore MyMethod messages.-->
    <filter type="log4net.F ilter.PropertyF ilter">
    <key value="MethodNa me"/>
    <stringToMatc h value="MyMethod "/>
    <acceptOnMatc h value="false"/>
    </filter>
    </appender>


Working...