i having following xml config log4j 3 appenders. , want configure logger following way:
all messages more info written stdout , global log file appenders
but class oauth want have log file oauthfile
some classes filtered , write messages log on error level can achieved
<logger name="application" level="error" />
some classes filtered , write messages own log file. solved additivity equal false flag.
<logger name="mapactor" level="debug" additivity="false"> <appender-ref ref="mapactorfile" /> </logger>
but how can solve 2nd problem. folowing configuration produces debug , error messages in stdout and! in oauthfile
<configuration> ... <appender name="stdout" ...></appender> <appender name="file" ...> </appender> <appender name="oauthfile" ...> </appender> ... <logger name="controllers.oauth" level="debug" additivity="false"> <appender-ref ref="oauthfile" /> </logger> <root level="info"> <appender-ref ref="stdout" /> <appender-ref ref="file" /> </root> </configuration>
actually have found solution second task. should make 2 stdout , file appenders - 1 general logging , second 1 filtering
<appender name="stdout" class="ch.qos.logback.core.consoleappender"> <encoder> <pattern>%d{hh:mm:ss.sss} %coloredlevel %cyan(%logger{15}) %message%n%xexception{5}</pattern> </encoder> </appender> <appender name="stdouterr" class="ch.qos.logback.core.consoleappender"> <filter class="ch.qos.logback.classic.filter.thresholdfilter"> <level>warn</level> </filter> <encoder> <pattern>%d{hh:mm:ss.sss} %coloredlevel %cyan(%logger{15}) %message%n%xexception{5}</pattern> </encoder> </appender>
and use second appender-ref classes should produce error log general stdout here:
<logger name="mapactor" level="debug" additivity="false"> <appender-ref ref="mapactorfileappender" /> <appender-ref ref="stdouterr" /> </logger>
Comments
Post a Comment