logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacob Kjome" <h...@visi.com>
Subject Log4j Extras ExpressionFilter issue
Date Tue, 02 Oct 2012 20:10:06 GMT

I'm trying to use the ExpressionFilter [1] from Log4j Extras to limit logging 
for a particular appender to those cases where MDC contains a "url" entry that 
equals some specific value.  But I get an error from Log4j saying "Invalid 
EQUALS rule - MDC.url is not a supported field" (see below for complete error 
output from Log4j).  I'm using the latest versions of Log4j-1.x and 
Log4j-extras.  Here's the relevant config...

<appender...>
    ....   
    <filter class="org.apache.log4j.filter.ExpressionFilter">
        <param name="Expression" value="MDC.url == 
'http://somedomain/somepath'"/>
    </filter>
</appender>

Based on the documentation [2] and commit comment [3] I found, it seems like 
this should work.  What am I missing?


Here's the complete error output from Log4j...

log4j:ERROR Could not create an Appender. Reported error follows.
java.lang.IllegalArgumentException: Invalid EQUALS rule - MDC.url is not a 
supported field
        at org.apache.log4j.rule.EqualsRule.<init>(EqualsRule.java:62)
        at org.apache.log4j.rule.EqualsRule.getRule(EqualsRule.java:100)
        at org.apache.log4j.rule.EqualsRule.getRule(EqualsRule.java:85)
        at org.apache.log4j.rule.RuleFactory.getRule(RuleFactory.java:154)
        at 
org.apache.log4j.rule.ExpressionRule$PostFixExpressionCompiler.compileExpression(ExpressionRule.java:149)
        at 
org.apache.log4j.rule.ExpressionRule.getRule(ExpressionRule.java:100)
        at 
org.apache.log4j.filter.ExpressionFilter.activateOptions(ExpressionFilter.java:95)
        at 
org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
        at 
org.apache.log4j.xml.DOMConfigurator.parseFilters(DOMConfigurator.java:380)
        at 
org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:273)
        at 
org.apache.log4j.xml.DOMConfigurator.findAppenderByName(DOMConfigurator.java:176)
        at 
org.apache.log4j.xml.DOMConfigurator.findAppenderByReference(DOMConfigurator.java:191)
        at 
org.apache.log4j.xml.DOMConfigurator.parseChildrenOfLoggerElement(DOMConfigurator.java:523)
        at 
org.apache.log4j.xml.DOMConfigurator.parseRoot(DOMConfigurator.java:492)
        at 
org.apache.log4j.xml.DOMConfigurator.parse(DOMConfigurator.java:1006)
        at 
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:872)
        at 
org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:778)
        at 
org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)
        at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)
        at 
org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:64)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
        at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:281)


[1] 
http://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/filter/ExpressionFilter.html
[2] 
https://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/spi/LoggingEventFieldResolver.html
[3] 
http://mail-archives.apache.org/mod_mbox/logging-log4j-dev/200310.mbox/%3C20031027083531.85866.qmail@minotaur.apache.org%3E



Jake

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message