[logback-user] Problems with jaino evaluator

George, Kenneth V [NTK] Kenneth.V.George at sprint.com
Fri Jun 22 21:58:29 CEST 2012


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 at qos.ch [mailto:logback-user-bounces at 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 at 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.



More information about the Logback-user mailing list