0
我想为不同的消息层次使用不同布局的appender。我想出的所有解决方案都需要两个不同的appender,像这里:log4j2 - 一个appender中不同层次的不同布局
<Appender type="Console" name="STDOUT_D">
<Layout type="PatternLayout" pattern="[%-5p] %d %c - %m%n"/>
<Filters>
<ThresholdFilter level="fatal" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<ThresholdFilter level="warn" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="info" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
</Filters>
</Appender>
<Appender type="Console" name="STDOUT">
<Layout type="PatternLayout" pattern="[%-5p] %d %-60.60c - %m%n"/>
<Filters>
<ThresholdFilter level="fatal" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="error" onMatch="DENY" onMismatch="NEUTRAL"/>
<ThresholdFilter level="warn" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="NEUTRAL"/>
<ThresholdFilter level="debug" onMatch="DENY" onMismatch="NEUTRAL"/>
</Filters>
</Appender>
想法?
我在严格模式下使用XML配置。