[logback-user] Filter does not work on tomcat
Ceki Gülcü
ceki at qos.ch
Wed Jun 16 17:13:47 CEST 2010
Hello Patrick,
To see any errors emitted by the EvaluatorFilter, I suggest adding the
following line to you configuration file:
<statusListener
class="ch.qos.logback.core.status.OnConsoleStatusListener" />
By the way, have you placed janino.jar in your web-application's class path?
HTH,
On 16/06/2010 4:45 PM, Sager, Patrick wrote:
> Hello
>
> I'm using a filter expression to determine the format of my log message.
> When running the configuration within my JUnit tests, the filter works
> perfectly.
> However, when running on a tomcat v6.0 server (within eclipse), the
> filter gets ignored and all log entries are written twice.
>
> Here's the extract of my logback.xml file:
>
> <!-- Log file for events with an explicitly defined source -->
> <appender name="ROLLING_LOG_WITH_SOURCE"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> <!-- Accept only messages with an explicit source -->
> <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
>
> <evaluator>
> <expression>(mdc.get("source") != null)&&
> !((String)mdc.get("source")).isEmpty()</expression>
> </evaluator>
> <OnMatch>ACCEPT</OnMatch>
> <OnMismatch>DENY</OnMismatch>
> </filter>
> <file>/etc/foe/logs/LogFile.log</file>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
> <!-- rollover monthly and compression of log history -->
>
> <fileNamePattern>TestLogFile-%d{yyyy-MM}.%i.zip</fileNamePattern>
> <maxHistory>12</maxHistory>
> <timeBasedFileNamingAndTriggeringPolicy
>
> class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
> <!-- or whenever the file size reaches 1MB -->
> <maxFileSize>1MB</maxFileSize>
> </timeBasedFileNamingAndTriggeringPolicy>
> </rollingPolicy>
> <encoder>
> <pattern>%-5level %date{yyyy-MM-dd HH:mm:ss.SSS} [%thread]
> [%X{source}] %msg%n</pattern>
> </encoder>
> </appender>
>
> <!-- Log file for events with no explicitly defined source -->
> <appender name="ROLLING_LOG_WITHOUT_SOURCE"
> class="ch.qos.logback.core.rolling.RollingFileAppender">
> <!-- Accept discard messages with an explicit source -->
> <filter class="ch.qos.logback.core.filter.EvaluatorFilter">
>
> <evaluator>
> <expression>(mdc.get("source") != null)&&
> !((String)mdc.get("source")).isEmpty()</expression>
> </evaluator>
> <OnMatch>DENY</OnMatch>
> <OnMismatch>ACCEPT</OnMismatch>
> </filter>
> <file>/etc/foe/logs/LogFile.log</file>
> <rollingPolicy
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
> <!-- rollover monthly and compression of log history -->
>
> <fileNamePattern>TestLogFile-%d{yyyy-MM}.%i.zip</fileNamePattern>
> <maxHistory>12</maxHistory>
> <timeBasedFileNamingAndTriggeringPolicy
>
> class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
> <!-- or whenever the file size reaches 1MB -->
> <maxFileSize>1MB</maxFileSize>
> </timeBasedFileNamingAndTriggeringPolicy>
> </rollingPolicy>
> <encoder>
> <pattern>%-5level %date{yyyy-MM-dd HH:mm:ss.SSS} [%thread]
> [%file:%line] %msg%n</pattern>
> </encoder>
> </appender>
>
> Is this a known issue, that LogBack does not support filters under
> tomcat?
>
> Thanks for any help
> -- Patrick
More information about the Logback-user
mailing list