logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ITemplate <itempl...@hotmail.com>
Subject Re: Cannot get PropertyFilter to work
Date Wed, 05 May 2010 11:25:34 GMT

Hi,

Ok now I can get it to work but the reason I dont understand. I missed that
one other filter was uncommented. My problem is that I cannot mix a
StringMatchFilter with a PropertyFilter. I can mix either with other filters
without problems but they do not work together. Like so:

      <filter type="log4net.Filter.StringMatchFilter">
        <stringToMatch value="yet" />
        <acceptOnMatch value="false" />
      </filter>

      <filter type="log4net.Filter.PropertyFilter">
        <key value="ID" />
        <stringToMatch value="87e18d7e477349ef9713e19c40ea393a" />
        <acceptOnMatch value="true" />
      </filter>

      <filter type="log4net.Filter.DenyAllFilter" />

This does not work. However if I: 

   1) Remove StringMatchFilter, it works. 
   2) Remove PropertyFilter and set StringMatchFilter.acceptOnMatch="true",
it works.

Any clues why?

-- 
Werner


Yuriy Taraday wrote:
> 
> Yes, properties is the only way.
> I think, the best way to find out, what's wrong, is to step through
> log4net source with debugger.
> 
> On Wed, May 5, 2010 at 2:54 PM, ITemplate <itemplate@hotmail.com> wrote:
>>
>> Hi,
>>
>> Tried that already both Stacks and Properties - same outcome. My issue
>> here
>> is that I need to append some key-value pair for each log entry - and
>> then
>> in configuration I must setup that specific key-value pairs should result
>> in
>> logging to multiple appenders. The properties seems like the only way to
>> do
>> this correct?
>>
>> Only have to find out why this filter isn't returning true.
>>
>> --
>> Werner
>>
>>
>>
>> Yuriy Taraday wrote:
>>>
>>> As I understand, this filter checks TreadContext properties, not
>>> LoggingEvent properties. You should try
>>> log4net.ThreadContext.Properties["ID"] =
>>> "87e18d7e477349ef9713e19c40ea393a";
>>>
>>> On Wed, May 5, 2010 at 2:26 PM, ITemplate <itemplate@hotmail.com> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have an appender that has 1 PropertyFilter like so:
>>>>
>>>>     <filter type="log4net.Filter.PropertyFilter">
>>>>        <key value="ID" />
>>>>        <stringToMatch value="87e18d7e477349ef9713e19c40ea393a" />
>>>>        <acceptOnMatch value="true" />
>>>>      </filter>
>>>>      <filter type="log4net.Filter.DenyAllFilter" />
>>>>
>>>> In code I am using ILogger like so:
>>>>
>>>>      log4net.Core.LoggingEvent ev = new log4net.Core.LoggingEvent(...);
>>>>      ev.Properties["ID"] = "87e18d7e477349ef9713e19c40ea393a";
>>>>
>>>> If I remove that filter the log is written alright. All other filters I
>>>> have
>>>> tested are working correct. If I run debug mode I can see log4net
>>>> discovering the propertyFilter correct. But it never kicks in. Where is
>>>> my
>>>> error?
>>>>
>>>> --
>>>> Werner
>>>>
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Cannot-get-PropertyFilter-to-work-tp28459133p28459133.html
>>>> Sent from the Log4net - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/Cannot-get-PropertyFilter-to-work-tp28459133p28459340.html
>> Sent from the Log4net - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://old.nabble.com/Cannot-get-PropertyFilter-to-work-tp28459133p28459600.html
Sent from the Log4net - Users mailing list archive at Nabble.com.


Mime
View raw message