You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by Billy Barnum <b....@comcast.net> on 2005/11/29 21:48:58 UTC

Trouble with PropertyFilter

I'm having trouble making a PropertyFilter work with some custom properties
of mine, and the archives didn't turn up anything. I'm probably not
understanding what PropertyFiltering is or am fat-fingering something; help
appreciated.

Expected Behavior: a certain FileAppender named 'AssertionException' will
only contain Events with a custom property 'LogEventCategory' set to a value
of 'AssertionHandling'.
Actual Behavior: no filtering takes place; all events logged to this
appender's output file.

The appender definition is:

<appender name="AssertionException" type="log4net.Appender.FileAppender">
	<filter type="log4net.Filter.PropertyFilter">
		<Key value="LogEventCategory" />
		<StringToMatch value="AssertionHandling" />
	</filter>
	<file value="..\..\AssertionException.txt" />
	<appendToFile value="false" />
	<layout type="log4net.Layout.PatternLayout">
		<conversionPattern value="[%date] [%thread] [%-5level]
[%property{LogEventContext}] [%property{LogEventCategory}] [%logger] [%ndc]
[%property{LogEventType}] [%property{LogEventId}]
[%property{LogEventUserId}] [%message]%newline" />
	</layout>
</appender>

Internal debugging output shows nothing untoward that I can see; I found the
following:

log4net: XmlHierarchyConfigurator: Loading Appender [AssertionException]
type: [log4net.Appender.FileAppender]
log4net: XmlHierarchyConfigurator: Setting Property [Key] to String value
[LogEventCategory]
log4net: XmlHierarchyConfigurator: Setting Property [StringToMatch] to
String value [AssertionHandling]
log4net: XmlHierarchyConfigurator: Setting Collection Property [AddFilter]
to object [log4net.Filter.PropertyFilter]

Here's subset of log output showing property 'LogEventCategory' values of
'ExecutionTrace' (not desired) and 'AssertionHandling':

[2005-11-29 12:18:23,159] [8164] [DEBUG] [BMTSecurity] [ExecutionTrace]
[BMT.Shared.Security.Guard.SecurityGuard] [(null)] [EndMethod]
[Authenticate] [BMT\bbarnum] [End Authenticate()]
[2005-11-29 12:18:23,159] [8164] [FATAL] [NUnit] [AssertionHandling]
[BMT.Shared.Security.Test.tSecurityGuard] [(null)] [AssertionException]
[Authenticate_0002] [BMT\bbarnum] [===== Exception # 0=====
ExceptionType: AssertionException
Message: 
Source: nunit.framework
StackTrace:    at NUnit.Framework.Assert.Fail(String message, Object[] args)
   at NUnit.Framework.Assert.IsTrue(Boolean condition)
   at BMT.Shared.Security.Test.tSecurityGuard.Authenticate_0002() in
c:\data\code\visual studio
projects\bmt\shared\vertical\bmt.shared.vl.security\test\class\tsecurityguar
d.cs:line 123
TargetSite: Void Fail(System.String, System.Object[])
]

So what am I not getting, here?

-BillyB

WILLIAM BARNUM
b.barnum@comcast.net
 


RE: Trouble with PropertyFilter

Posted by Billy Barnum <b....@comcast.net>.
As always, very helpful, Ron. Thanks, that worked.

Just so I'm clear, though ...

If these filters are additive, then why do I get everything if I don't
specify any filter at all? And if they're subtractive, why do I need the
DenyAllFilter at all? Or is there something special about DenyAllFilter?

See what I mean? How do these filters work together? Is there a
documentation section that outlines it so you don't hafta 'splain? I didn't
see one.

-BillyB


WILLIAM BARNUM
b.barnum@comcast.net
 

-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com] 
Sent: Tuesday, November 29, 2005 3:13 PM
To: Log4NET User
Subject: Re: Trouble with PropertyFilter

 <filter type="log4net.Filter.PropertyFilter">
  <Key value="LogEventCategory" />
  <StringToMatch value="AssertionHandling" />
 </filter>
 <filter type="log4net.Filter.DenyAllFilter" />

--- Billy Barnum <b....@comcast.net> wrote:

> I'm having trouble making a PropertyFilter work with some custom
> properties
> of mine, and the archives didn't turn up anything. I'm probably not
> understanding what PropertyFiltering is or am fat-fingering
> something; help
> appreciated.
> 
> Expected Behavior: a certain FileAppender named 'AssertionException'
> will
> only contain Events with a custom property 'LogEventCategory' set to
> a value
> of 'AssertionHandling'.
> Actual Behavior: no filtering takes place; all events logged to this
> appender's output file.
> 
> The appender definition is:
> 
> <appender name="AssertionException"
> type="log4net.Appender.FileAppender">
> 	<filter type="log4net.Filter.PropertyFilter">
> 		<Key value="LogEventCategory" />
> 		<StringToMatch value="AssertionHandling" />
> 	</filter>
> 	<file value="..\..\AssertionException.txt" />
> 	<appendToFile value="false" />
> 	<layout type="log4net.Layout.PatternLayout">
> 		<conversionPattern value="[%date] [%thread] [%-5level]
> [%property{LogEventContext}] [%property{LogEventCategory}] [%logger]
> [%ndc]
> [%property{LogEventType}] [%property{LogEventId}]
> [%property{LogEventUserId}] [%message]%newline" />
> 	</layout>
> </appender>
> 
> Internal debugging output shows nothing untoward that I can see; I
> found the
> following:
> 
> log4net: XmlHierarchyConfigurator: Loading Appender
> [AssertionException]
> type: [log4net.Appender.FileAppender]
> log4net: XmlHierarchyConfigurator: Setting Property [Key] to String
> value
> [LogEventCategory]
> log4net: XmlHierarchyConfigurator: Setting Property [StringToMatch]
> to
> String value [AssertionHandling]
> log4net: XmlHierarchyConfigurator: Setting Collection Property
> [AddFilter]
> to object [log4net.Filter.PropertyFilter]
> 
> Here's subset of log output showing property 'LogEventCategory'
> values of
> 'ExecutionTrace' (not desired) and 'AssertionHandling':
> 
> [2005-11-29 12:18:23,159] [8164] [DEBUG] [BMTSecurity]
> [ExecutionTrace]
> [BMT.Shared.Security.Guard.SecurityGuard] [(null)] [EndMethod]
> [Authenticate] [BMT\bbarnum] [End Authenticate()]
> [2005-11-29 12:18:23,159] [8164] [FATAL] [NUnit] [AssertionHandling]
> [BMT.Shared.Security.Test.tSecurityGuard] [(null)]
> [AssertionException]
> [Authenticate_0002] [BMT\bbarnum] [===== Exception # 0=====
> ExceptionType: AssertionException
> Message: 
> Source: nunit.framework
> StackTrace:    at NUnit.Framework.Assert.Fail(String message,
> Object[] args)
>    at NUnit.Framework.Assert.IsTrue(Boolean condition)
>    at BMT.Shared.Security.Test.tSecurityGuard.Authenticate_0002() in
> c:\data\code\visual studio
>
projects\bmt\shared\vertical\bmt.shared.vl.security\test\class\tsecurityguar
> d.cs:line 123
> TargetSite: Void Fail(System.String, System.Object[])
> ]
> 
> So what am I not getting, here?
> 
> -BillyB
> 
> WILLIAM BARNUM
> b.barnum@comcast.net
>  
> 
> 


Re: Trouble with PropertyFilter

Posted by Ron Grabowski <ro...@yahoo.com>.
 <filter type="log4net.Filter.PropertyFilter">
  <Key value="LogEventCategory" />
  <StringToMatch value="AssertionHandling" />
 </filter>
 <filter type="log4net.Filter.DenyAllFilter" />

--- Billy Barnum <b....@comcast.net> wrote:

> I'm having trouble making a PropertyFilter work with some custom
> properties
> of mine, and the archives didn't turn up anything. I'm probably not
> understanding what PropertyFiltering is or am fat-fingering
> something; help
> appreciated.
> 
> Expected Behavior: a certain FileAppender named 'AssertionException'
> will
> only contain Events with a custom property 'LogEventCategory' set to
> a value
> of 'AssertionHandling'.
> Actual Behavior: no filtering takes place; all events logged to this
> appender's output file.
> 
> The appender definition is:
> 
> <appender name="AssertionException"
> type="log4net.Appender.FileAppender">
> 	<filter type="log4net.Filter.PropertyFilter">
> 		<Key value="LogEventCategory" />
> 		<StringToMatch value="AssertionHandling" />
> 	</filter>
> 	<file value="..\..\AssertionException.txt" />
> 	<appendToFile value="false" />
> 	<layout type="log4net.Layout.PatternLayout">
> 		<conversionPattern value="[%date] [%thread] [%-5level]
> [%property{LogEventContext}] [%property{LogEventCategory}] [%logger]
> [%ndc]
> [%property{LogEventType}] [%property{LogEventId}]
> [%property{LogEventUserId}] [%message]%newline" />
> 	</layout>
> </appender>
> 
> Internal debugging output shows nothing untoward that I can see; I
> found the
> following:
> 
> log4net: XmlHierarchyConfigurator: Loading Appender
> [AssertionException]
> type: [log4net.Appender.FileAppender]
> log4net: XmlHierarchyConfigurator: Setting Property [Key] to String
> value
> [LogEventCategory]
> log4net: XmlHierarchyConfigurator: Setting Property [StringToMatch]
> to
> String value [AssertionHandling]
> log4net: XmlHierarchyConfigurator: Setting Collection Property
> [AddFilter]
> to object [log4net.Filter.PropertyFilter]
> 
> Here's subset of log output showing property 'LogEventCategory'
> values of
> 'ExecutionTrace' (not desired) and 'AssertionHandling':
> 
> [2005-11-29 12:18:23,159] [8164] [DEBUG] [BMTSecurity]
> [ExecutionTrace]
> [BMT.Shared.Security.Guard.SecurityGuard] [(null)] [EndMethod]
> [Authenticate] [BMT\bbarnum] [End Authenticate()]
> [2005-11-29 12:18:23,159] [8164] [FATAL] [NUnit] [AssertionHandling]
> [BMT.Shared.Security.Test.tSecurityGuard] [(null)]
> [AssertionException]
> [Authenticate_0002] [BMT\bbarnum] [===== Exception # 0=====
> ExceptionType: AssertionException
> Message: 
> Source: nunit.framework
> StackTrace:    at NUnit.Framework.Assert.Fail(String message,
> Object[] args)
>    at NUnit.Framework.Assert.IsTrue(Boolean condition)
>    at BMT.Shared.Security.Test.tSecurityGuard.Authenticate_0002() in
> c:\data\code\visual studio
>
projects\bmt\shared\vertical\bmt.shared.vl.security\test\class\tsecurityguar
> d.cs:line 123
> TargetSite: Void Fail(System.String, System.Object[])
> ]
> 
> So what am I not getting, here?
> 
> -BillyB
> 
> WILLIAM BARNUM
> b.barnum@comcast.net
>  
> 
>