Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can create a log that captures all warnings, errors, etc. from the main process log, but excludes certain "common" warnings. The techniques shown can be adapted to filter messages out of the other logs, if so desired. The example also limits the size of the stack traces from Java exceptions.

Code Block
xml
xml
    <!-- Add an appender below the existing ones. -->
    <appender name="IDP_WARN" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <!-- Example of filtering out messages by searching the log message. -->
        <filter class="ch.qos.logback.core.filter.EvaluatorFilter">      
            <evaluator>
                <expression>event.getMessage().indexOf("trying its failover connector") >= 0</expression>
            </evaluator>
            <OnMismatch>NEUTRAL</OnMismatch>
            <OnMatch>DENY</OnMatch>
        </filter>
        <!-- Suppress anything above below WARN. -->
        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
            <level>WARN</level>
        </filter>
        <File>/opt/shibboleth-idp/logs/idp-warn.log</File>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>/opt/shibboleth-idp/logs/idp-warn-%d{yyyy-MM-dd}.log.gz</FileNamePattern>
        </rollingPolicy>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <charset>UTF-8</charset>
            <Pattern>%date{HH:mm:ss.SSS} - %level [%logger:%line] - %msg%n%ex{3}</Pattern>
        </encoder>
    </appender>

    <!-- Modify root logging category at end of file and add new appender. -->
    <root level="ERROR">
        <appender-ref ref="IDP_PROCESS" />
        <appender-ref ref="IDP_WARN" />
    </root>