Ok, but it takes too long for me.
I have written an own Filter. See Attachment.
Scott Deboy <[EMAIL PROTECTED]> wrote:
BTW, you will be able to use an ExpressionFilter to build regexps that
can evaluate message text, MDC entries, etc (part of a log4j release
soon hopefully).
Scott Deboy
Principal Engineer
COMOTIV SYSTEMS
111 SW Columbia Street Ste. 950
Portland, OR 97201
Office: 503.224.7496
Direct Line: 503.821.6482
Cell: 503.997.1367
Fax: 503.222.0185
[EMAIL PROTECTED]
www.comotivsystems.com
-----Original Message-----
From: Hans Schwaebli [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 12, 2007 4:42 AM
To: Log4J Users List
Subject: Re: Recipients of email appender depending on log message,
possible?
I think it is no great problem to write a custom filter which reads the
MDC content, although it would take some time to write and to test and
maintain it.
So I rather would like to use a addon or something, if it exists,
which does this.
James Stauffer wrote:
I believe I have seen examples on the mailing list so there should be
examples in the archive.
On 7/11/07, Hans Schwaebli wrote:
> Come on... You know what I mean. I didn't find any good manual or
tutorial freely available for log4j. And I searched for half an hour.
Excuse me if I then dare to ask here. So if anyone can tell me, I would
be glad.
>
>
> James Stauffer wrote: Did you search the mailing list archives, wiki,
and javadocs?
>
> On 7/11/07, Hans Schwaebli wrote:
> > It seems this is a solution. But I couldn't find a site where using
log4j filters is described. Any idea?
> >
--
James Stauffer http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket:
mail, news, photos & more.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------
Never miss an email again!
Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.
import org.apache.log4j.spi.Filter;
import org.apache.log4j.spi.LoggingEvent;
/**
This is a very simple filter based on filtering by MDC key and value.
*/
public class MDCFilter extends Filter
{
/**
Do we return ACCEPT when a match occurs. Default is
<code>false</code>, so that later filters get run by default */
boolean acceptOnMatch = false;
String regexToMatch;
String mdcKey;
/**
Return the decision of this filter.
*/
public int decide(LoggingEvent event)
{
String mdcValue = (String) event.getMDC(mdcKey);
boolean matches = mdcValue.matches(regexToMatch);
if ((matches && acceptOnMatch) || (!matches && !acceptOnMatch))
{
return Filter.ACCEPT;
}
else
{
return Filter.DENY;
}
}
public String getRegexToMatch()
{
return regexToMatch;
}
public void setRegexToMatch(String regexToMatch)
{
this.regexToMatch = regexToMatch;
}
public String getMDCKey()
{
return mdcKey;
}
public void setMDCKey(String mdcKey)
{
this.mdcKey = mdcKey;
}
/**
Get the value of the <code>AcceptOnMatch</code> option.
*/
public boolean getAcceptOnMatch()
{
return acceptOnMatch;
}
/**
Set the <code>AcceptOnMatch</code> option.
*/
public void setAcceptOnMatch(boolean acceptOnMatch)
{
this.acceptOnMatch = acceptOnMatch;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]