Problems with jaino evaluator

Good afternoon. I have a situation where I need to log information to 2 separate files, but under different conditions, for the same context/class files. Basically, I have 2 files: 1 log, 1 alarm_log. I need to set the level for reporting to INFO, but only log WARN/ERROR messages to alarm_log when a MDC value of "SEND_ALARM" is set. I have tried to place a <filter> of type "ch.qos.logback.core.filter.EvaluatorFilter" and cannot seem to get it to work, messages of Level INFO show-up in the alarm_log. Can this even be done (maybe I am just using it wrong)? Here is the section of my logback.xml file specifying the appender: <appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.core.filter.EvaluatorFilter"> <evaluator> <expression> if (mdc == null || mdc.get("SEND_ALARM") == null) return false; return true; </expression> </evaluator> </filter> <file>logs/alarms.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- daily rollover --> <fileNamePattern>logs/archive/logFile.%d{yyyy-MM-dd}.log</fileNamePattern> <!-- keep 30 days' worth of history --> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%date{MMM dd, yyyy hh:mm:ss} %-5level %msg%n</pattern> </encoder> </appender> Thanks. ________________________________ This e-mail may contain Sprint Nextel proprietary information intended for the sole use of the recipient(s). Any use by others is prohibited. If you are not the intended recipient, please contact the sender and delete all copies of the message.

Hi George, From what could gather, you want to set an evaluaor[1] not a filter. You should remove have the enclosing filter element as shown below: <appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender"> <evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator"> .. </evaluator> </appender> HTH, [1] http://logback.qos.ch/manual/appenders.html#smtpAppender_Evaluator On 20.06.2012 19:34, George, Kenneth V [NTK] wrote:
Good afternoon.
I have a situation where I need to log information to 2 separate files, but under different conditions, for the same context/class files.
Basically, I have 2 files: 1 log, 1 alarm_log.
I need to set the level for reporting to INFO, but only log WARN/ERROR messages to alarm_log when a MDC value of “SEND_ALARM” is set. I have tried to place a <filter> of type “ch.qos.logback.core.filter.EvaluatorFilter” and cannot seem to get it to work, messages of Level INFO show-up in the alarm_log.
Can this even be done (maybe I am just using it wrong)? Here is the section of my logback.xml file specifying the appender:
<appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<expression>
if (mdc == null || mdc.get("SEND_ALARM") == null)
return false;
return true;
</expression>
</evaluator>
</filter>
<file>logs/alarms.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>logs/archive/logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date{MMM dd, yyyy hh:mm:ss} %-5level %msg%n</pattern>
</encoder>
</appender>
Thanks.
-- Ceki http://twitter.com/#!/ceki

This doesn't work. I have changed the code, but I get every entry from the logger in the ALARM.LOG file. Here is what I now have in logback.xml <appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender"> <evaluator class="ch.qos.logback.core.filter.EvaluatorFilter"> <expression> if (mdc == null || mdc.get("SEND_ALARM") == null) return false; return true; </expression> </evaluator> <file>logs/alarms.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- daily rollover --> <fileNamePattern>logs/archive/logFile.%d{yyyy-MM-dd}.log</fileNamePattern> <!-- keep 30 days' worth of history --> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%date{MMM dd, yyyy hh:mm:ss} %-5level %msg%n</pattern> </encoder> </appender> -----Original Message----- From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of ceki Sent: Friday, June 22, 2012 2:54 PM To: logback users list Subject: Re: [logback-user] Problems with jaino evaluator Hi George, From what could gather, you want to set an evaluaor[1] not a filter. You should remove have the enclosing filter element as shown below: <appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender"> <evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator"> .. </evaluator> </appender> HTH, [1] http://logback.qos.ch/manual/appenders.html#smtpAppender_Evaluator On 20.06.2012 19:34, George, Kenneth V [NTK] wrote:
Good afternoon.
I have a situation where I need to log information to 2 separate files, but under different conditions, for the same context/class files.
Basically, I have 2 files: 1 log, 1 alarm_log.
I need to set the level for reporting to INFO, but only log WARN/ERROR messages to alarm_log when a MDC value of "SEND_ALARM" is set. I have tried to place a <filter> of type "ch.qos.logback.core.filter.EvaluatorFilter" and cannot seem to get it to work, messages of Level INFO show-up in the alarm_log.
Can this even be done (maybe I am just using it wrong)? Here is the section of my logback.xml file specifying the appender:
<appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<expression>
if (mdc == null || mdc.get("SEND_ALARM") == null)
return false;
return true;
</expression>
</evaluator>
</filter>
<file>logs/alarms.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>logs/archive/logFile.%d{yyyy-MM-dd}.log</fileNamePatt ern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date{MMM dd, yyyy hh:mm:ss} %-5level %msg%n</pattern>
</encoder>
</appender>
Thanks.
-- Ceki http://twitter.com/#!/ceki _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user ________________________________ This e-mail may contain Sprint Nextel proprietary information intended for the sole use of the recipient(s). Any use by others is prohibited. If you are not the intended recipient, please contact the sender and delete all copies of the message.

Sorry....the text should read: <evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator"> ... </evaluator> Doesn't this evaluator only work for SMTP appenders? -----Original Message----- From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of George, Kenneth V [NTK] Sent: Friday, June 22, 2012 2:58 PM To: logback users list Subject: Re: [logback-user] Problems with jaino evaluator This doesn't work. I have changed the code, but I get every entry from the logger in the ALARM.LOG file. Here is what I now have in logback.xml <appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender"> <evaluator class="ch.qos.logback.core.filter.EvaluatorFilter"> <expression> if (mdc == null || mdc.get("SEND_ALARM") == null) return false; return true; </expression> </evaluator> <file>logs/alarms.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- daily rollover --> <fileNamePattern>logs/archive/logFile.%d{yyyy-MM-dd}.log</fileNamePattern> <!-- keep 30 days' worth of history --> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%date{MMM dd, yyyy hh:mm:ss} %-5level %msg%n</pattern> </encoder> </appender> -----Original Message----- From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of ceki Sent: Friday, June 22, 2012 2:54 PM To: logback users list Subject: Re: [logback-user] Problems with jaino evaluator Hi George, From what could gather, you want to set an evaluaor[1] not a filter. You should remove have the enclosing filter element as shown below: <appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender"> <evaluator class="ch.qos.logback.classic.boolex.JaninoEventEvaluator"> .. </evaluator> </appender> HTH, [1] http://logback.qos.ch/manual/appenders.html#smtpAppender_Evaluator On 20.06.2012 19:34, George, Kenneth V [NTK] wrote:
Good afternoon.
I have a situation where I need to log information to 2 separate files, but under different conditions, for the same context/class files.
Basically, I have 2 files: 1 log, 1 alarm_log.
I need to set the level for reporting to INFO, but only log WARN/ERROR messages to alarm_log when a MDC value of "SEND_ALARM" is set. I have tried to place a <filter> of type "ch.qos.logback.core.filter.EvaluatorFilter" and cannot seem to get it to work, messages of Level INFO show-up in the alarm_log.
Can this even be done (maybe I am just using it wrong)? Here is the section of my logback.xml file specifying the appender:
<appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<expression>
if (mdc == null || mdc.get("SEND_ALARM") == null)
return false;
return true;
</expression>
</evaluator>
</filter>
<file>logs/alarms.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>logs/archive/logFile.%d{yyyy-MM-dd}.log</fileNamePatt ern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date{MMM dd, yyyy hh:mm:ss} %-5level %msg%n</pattern>
</encoder>
</appender>
Thanks.
-- Ceki http://twitter.com/#!/ceki _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user ________________________________ This e-mail may contain Sprint Nextel proprietary information intended for the sole use of the recipient(s). Any use by others is prohibited. If you are not the intended recipient, please contact the sender and delete all copies of the message. _______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user ________________________________ This e-mail may contain Sprint Nextel proprietary information intended for the sole use of the recipient(s). Any use by others is prohibited. If you are not the intended recipient, please contact the sender and delete all copies of the message.

On Wed, Jun 20, 2012 at 1:34 PM, George, Kenneth V [NTK] < Kenneth.V.George@sprint.com> wrote:
Good afternoon.
I have a situation where I need to log information to 2 separate files, but under different conditions, for the same context/class files.
Basically, I have 2 files: 1 log, 1 alarm_log.
I need to set the level for reporting to INFO, but only log WARN/ERROR messages to alarm_log when a MDC value of “SEND_ALARM” is set. I have tried to place a <filter> of type “ch.qos.logback.core.filter.EvaluatorFilter” and cannot seem to get it to work, messages of Level INFO show-up in the alarm_log.
Can this even be done (maybe I am just using it wrong)? Here is the section of my logback.xml file specifying the appender:
<appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
<evaluator>
<expression>
if (mdc == null || mdc.get("SEND_ALARM") == null)
No need to check for (mdc == null) because it's guaranteed to not be null in versions 0.9.30 and later.
return false;
return true;
</expression>
</evaluator>
</filter>
<file>logs/alarms.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- daily rollover -->
<fileNamePattern>logs/archive/logFile.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- keep 30 days' worth of history -->
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date{MMM dd, yyyy hh:mm:ss} %-5level %msg%n</pattern>
</encoder>
</appender>
Try this: <appender name="ALARM" class="ch.qos.logback.core.rolling.RollingFileAppender"> <filter class="ch.qos.logback.core.filter.JaninoEvaluatorFilter"> <evaluator> <expression>return (mdc.get("SEND_ALARM") != null) && (level > INFO);</expression> </evaluator> <OnMismatch>DENY</OnMismatch> <OnMatch>ACCEPT</OnMatch> </filter> <file>logs/alarms.log</file> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <!-- daily rollover --> <fileNamePattern>logs/archive/logFile.%d{yyyy-MM-dd}.log</fileNamePattern> <!-- keep 30 days' worth of history --> <maxHistory>30</maxHistory> </rollingPolicy> <encoder> <pattern>%date{MMM dd, yyyy hh:mm:ss} %-5level %msg%n</pattern> </encoder> </appender>

I get this error. 15:44:33,114 |-ERROR in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Could not create component [filter] of type [ch.qos.logback.core.filter.JaninoEvaluatorFilter] java.lang.ClassNotFoundException: ch.qos.logback.core.filter.JaninoEvaluatorFilter at java.lang.ClassNotFoundException: ch.qos.logback.core.filter.JaninoEvaluatorFilter From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of Tony Trinh Sent: Friday, June 22, 2012 3:21 PM To: logback users list Subject: Re: [logback-user] Problems with jaino evaluator On Fri, Jun 22, 2012 at 4:10 PM, Tony Trinh <tony19@gmail.com<mailto:tony19@gmail.com>> wrote: <expression>return (mdc.get("SEND_ALARM") != null) && (level > INFO);</expression> The ampersands need to be escaped: <expression>return (mdc.get("SEND_ALARM") != null) && (level > INFO);</expression> ________________________________ This e-mail may contain Sprint Nextel proprietary information intended for the sole use of the recipient(s). Any use by others is prohibited. If you are not the intended recipient, please contact the sender and delete all copies of the message.

On Fri, Jun 22, 2012 at 4:47 PM, George, Kenneth V [NTK] < Kenneth.V.George@sprint.com> wrote:
I get this error.
15:44:33,114 |-ERROR in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Could not create component [filter] of type [ch.qos.logback.core.filter.JaninoEvaluatorFilter] java.lang.ClassNotFoundException: ch.qos.logback.core.filter.JaninoEvaluatorFilter
at java.lang.ClassNotFoundException: ch.qos.logback.core.filter.JaninoEvaluatorFilter
Change the filter class to ch.qos.logback.core.filter.EvaluatorFilter.

Ok, so I made the change and I do not get the error now. However, I still am getting text in the alarm.txt file that should not be there. I changed the evaluation for level > INFO to be level == ERROR. I am still getting info and debug messages in the alarm file. Also, SEND_ALARM has not been set in the code, yet I am getting log messages. From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of Tony Trinh Sent: Friday, June 22, 2012 3:54 PM To: logback users list Subject: Re: [logback-user] Problems with jaino evaluator On Fri, Jun 22, 2012 at 4:47 PM, George, Kenneth V [NTK] <Kenneth.V.George@sprint.com<mailto:Kenneth.V.George@sprint.com>> wrote: I get this error. 15:44:33,114 |-ERROR in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Could not create component [filter] of type [ch.qos.logback.core.filter.JaninoEvaluatorFilter] java.lang.ClassNotFoundException: ch.qos.logback.core.filter.JaninoEvaluatorFilter at java.lang.ClassNotFoundException: ch.qos.logback.core.filter.JaninoEvaluatorFilter Change the filter class to ch.qos.logback.core.filter.EvaluatorFilter. ________________________________ This e-mail may contain Sprint Nextel proprietary information intended for the sole use of the recipient(s). Any use by others is prohibited. If you are not the intended recipient, please contact the sender and delete all copies of the message.

On Fri, Jun 22, 2012 at 4:58 PM, George, Kenneth V [NTK] < Kenneth.V.George@sprint.com> wrote:
Ok, so I made the change and I do not get the error now. However, I still am getting text in the alarm.txt file that should not be there. I changed the evaluation for level > INFO to be level == ERROR. I am still getting info and debug messages in the alarm file. Also, SEND_ALARM has not been set in the code, yet I am getting log messages.
I can't reproduce your symptoms (my alarms.log contains only messages that pass the filter). Are you sure you're not looking at a stale log? What library versions are you working with? My library versions: - logback-core-1.0.6.jar - logback-classic-1.0.6.jar - slf4j-api-1.6.6.jar

I clear-out the logs before I start my app. I am using earlier versions of the libraries though... logback-core-1.0.0.jar logback-classic-1.0.0.jar slf4j-api-1.6.4.jar From: logback-user-bounces@qos.ch [mailto:logback-user-bounces@qos.ch] On Behalf Of Tony Trinh Sent: Friday, June 22, 2012 4:11 PM To: logback users list Subject: Re: [logback-user] Problems with jaino evaluator On Fri, Jun 22, 2012 at 4:58 PM, George, Kenneth V [NTK] <Kenneth.V.George@sprint.com<mailto:Kenneth.V.George@sprint.com>> wrote: Ok, so I made the change and I do not get the error now. However, I still am getting text in the alarm.txt file that should not be there. I changed the evaluation for level > INFO to be level == ERROR. I am still getting info and debug messages in the alarm file. Also, SEND_ALARM has not been set in the code, yet I am getting log messages. I can't reproduce your symptoms (my alarms.log contains only messages that pass the filter). Are you sure you're not looking at a stale log? What library versions are you working with? My library versions: * logback-core-1.0.6.jar * logback-classic-1.0.6.jar * slf4j-api-1.6.6.jar ________________________________ This e-mail may contain Sprint Nextel proprietary information intended for the sole use of the recipient(s). Any use by others is prohibited. If you are not the intended recipient, please contact the sender and delete all copies of the message.

On Fri, Jun 22, 2012 at 5:12 PM, George, Kenneth V [NTK] < Kenneth.V.George@sprint.com> wrote:
I clear-out the logs before I start my app. I am using earlier versions of the libraries though…
logback-core-1.0.0.jar
logback-classic-1.0.0.jar
slf4j-api-1.6.4.jar
Ok. Let us know if it works after you update.
participants (3)
-
ceki
-
George, Kenneth V [NTK]
-
Tony Trinh