If you can use log4j 1.3, you could use an ExpressionFilter, with the
expression:

CLASS ~= 'javax.naming' || CLASS ~= 'org.jnp.server'

With acceptonmatch to false

See JavaDoc for more info on the filter.

http://svn.apache.org/viewcvs.cgi/logging/log4j/trunk/src/java/org/apach
e/log4j/filter/ExpressionFilter.java?view=markup

Some of the keywords you can use are:
MSG, LOGGER, LEVEL, CLASS, FILE, LINE, METHOD, NDC, AND PROP.AAAA (which
allows you to filter on mdc with key AAAA)

Chainsaw describes this stuff in detail in the tutorial.

Scott

-----Original Message-----
From: Jeremy Whitlock [mailto:[EMAIL PROTECTED] 
Sent: Monday, October 31, 2005 1:01 PM
To: Log4J-User
Subject: Filter Based On Logging Class

Hey all,
I would like to implement a filter that would allow me to restrict
messages based on the class that is sending the LoggingEvent. So I could
have something like:

<filter class="my.filter.Class">
<param name="acceptOnMatch" value="false" /> <param name="expression"
value="javax.naming org.jnp.server" /> </filter>

And the filter would not log any class that created a LoggingEvent if
that class was in either of those packages. Is there one of these
available? If not, how should I go about writing one? I do not see how I
can get the class from the LoggingEvent.

Take care,
Jeremy

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to