logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Scott Deboy <scott.de...@gmail.com>
Subject Re: Log4j Extras ExpressionFilter issue
Date Thu, 04 Oct 2012 22:38:59 GMT
Hey Jake

I tried this in the latest developer snapshot of Chainsaw..I pulled up a
log in Chainsaw which contained info and debug entries (I didn't have a log
with trace).

And I added your URL value you provided in the 'marker' field of two of my
INFO entries

This expression:

(level <= debug) || (level == info && prop.marker == '
https://somedomain/somepath/somepage.do?someparam=someval&amp;anotherparam=anotherval
')

Gave me all of the debug entries and two info level entries..

It could be something weird with trace...or something weird with parsing
the &amp; ??? but...this should work..

Scott


On Wed, Oct 3, 2012 at 8:56 AM, Jacob Kjome <hoju@visi.com> wrote:

>
> Thanks Scott,
>
> However, while I didn't experience an error in parsing the expression this
> time, the expression seems to be, at least partially, ignored.
>
> Below is the relevant config, where com.mypackage.MyClass sets MDC (via
> SLF4J) with a "url" key and the currently processed URL as the value, then
> logs the page content for the URL at the TRACE level (with MDC removal of
> "url" immediately after logging the page content).  But rather than getting
> TRACE output for only the URL defined in the Expression, I get **all**
> TRACE output.  It's like it sees the "LEVEL == TRACE" but then ignores the
> "&&".  Thoughts?
>
>
>     <appender name="default" class="org.apache.log4j.**
> rolling.RollingFileAppender">
>         ...
>
>         <filter class="org.apache.log4j.**filter.ExpressionFilter">
>             <param name="Expression"
>                    value="( LEVEL >= DEBUG ) || ( LEVEL == TRACE
> &amp;&amp; PROP.url == 'https://somedomain/somepath/**
> somepage.do?someparam=someval&**amp;anotherparam=anotherval<https://somedomain/somepath/somepage.do?someparam=someval&anotherparam=anotherval>'
> )"/>
>         </filter>
>     </appender>
>
>     <logger name="com.mypackage.MyClass">
>         <level value="TRACE"/>
>     </logger>
>
>     <root>
>         <level value="WARN"/>
>         <appender-ref ref="default"/>
>     </root>
>
>
>
> On Tue, 2 Oct 2012 15:53:57 -0700
>  Scott Deboy <scott.deboy@gmail.com> wrote:
>
>> Try PROP.url == 'blah'
>>
>> MDC entries are really just set as properties of the log4j events.
>>
>> Scott
>>
>> On Tue, Oct 2, 2012 at 1:10 PM, Jacob Kjome <hoju@visi.com> wrote:
>>
>>
>>> 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/**<http://logging.apache.org/**log4j/companions/extras/**>
>>> apidocs/org/apache/log4j/****filter/ExpressionFilter.html<h**
>>> ttp://logging.apache.org/**log4j/companions/extras/**
>>> apidocs/org/apache/log4j/**filter/ExpressionFilter.html<http://logging.apache.org/log4j/companions/extras/apidocs/org/apache/log4j/filter/ExpressionFilter.html>
>>> >
>>> [2] https://logging.apache.org/****log4j/companions/extras/**<https://logging.apache.org/**log4j/companions/extras/**>
>>> apidocs/org/apache/log4j/spi/****LoggingEventFieldResolver.**html<
>>> https://logging.apache.**org/log4j/companions/extras/**
>>> apidocs/org/apache/log4j/spi/**LoggingEventFieldResolver.html<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<http:/**/mail-archives.apache.org/mod_**
>>> mbox/logging-log4j-dev/200310.**mbox/%3C20031027083531.85866.**
>>> qmail@minotaur.apache.org%3E<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@**loggi**ng.apache.org<http://logging.apache.org>
>>> <log4j-user-**unsubscribe@logging.apache.org<log4j-user-unsubscribe@logging.apache.org>
>>> **>
>>> For additional commands, e-mail: log4j-user-help@logging.**apac**he.org<http://apache.org>
>>> <log4j-user-help@**logging.apache.org<log4j-user-help@logging.apache.org>
>>> >
>>>
>>>
>>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: log4j-user-unsubscribe@**logging.apache.org<log4j-user-unsubscribe@logging.apache.org>
> For additional commands, e-mail: log4j-user-help@logging.**apache.org<log4j-user-help@logging.apache.org>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message