Error using Logback Marker in FileAppender

萝らか妹 提交于 2019-12-05 11:10:11

In SMTPAppender the evaluator is used for triggering. In FileAppender, you need to encapsulate the evaluator within a filter, an evaluator filter to be precise. Here is an example:

<property name="USER_HOME" value="c:/temp" />

<appender name="AUDIT_FILE" class="ch.qos.logback.core.FileAppender">        
    <!-- the filter element -->
    <filter class="ch.qos.logback.core.filter.EvaluatorFilter">   
      <evaluator class="ch.qos.logback.classic.boolex.OnMarkerEvaluator">
        <marker>APPEND_SYSLOG</marker>
      </evaluator>
     <onMismatch>DENY</onMismatch>
     <onMatch>NEUTRAL</onMatch>
   </filter>
    <file>${USER_HOME}/mw_syslog.log</file>        
    <encoder>
        <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
    </encoder>
</appender>

<root level="debug">
    <appender-ref ref="AUDIT_FILE" />
</root>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!