java - How to make logger.trace() and logger.info() work together -
i have issue logging trace function in distinct file info function, prepared classic log4j.xml file containing required configuration.
logger.info() working.
logger.trace() not working.
<appender name="file" class="org.apache.log4j.fileappender"> <param name="append" value="true" /> <param name="file" value="c:/logs/transaction.log" /> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d{yyyy-mm-dd hh:mm:ss} %-5p %c{1}:%l - %m%n" /> </layout> <filter class="org.apache.log4j.varia.levelrangefilter"> <param name="levelmin" value="trace" /> <param name="levelmax" value="trace" /> <param name="acceptonmatch" value="true" /> </filter> </appender> <appender name="fileinfo" class="org.apache.log4j.fileappender"> <param name="append" value="true" /> <param name="file" value="c:/logs/server.log" /> <layout class="org.apache.log4j.patternlayout"> <param name="conversionpattern" value="%d{yyyy-mm-dd hh:mm:ss} %-5p %c{1}:%l - %m%n" /> </layout> <filter class="org.apache.log4j.varia.levelrangefilter"> <param name="levelmin" value="info" /> <param name="levelmax" value="info" /> <param name="acceptonmatch" value="true" /> </filter> </appender> <logger name="ma.prg.net"> <level value="trace" /> <appender-ref ref="file" /> </logger> <logger name="ma.prg.net"> <level value="info" /> <appender-ref ref="fileinfo" /> </logger>
logger.trace() working fine before added fileinfo appender.
thanks in advance.
you cannot configure same logger twice. change logger configuration to:
<logger name="ma.prg.net"> <level value="trace" /> <appender-ref ref="file" /> <appender-ref ref="fileinfo" /> </logger>
with send logging message both appenders. configured each appender individually levelmin , levelmax, each filters out messages should print.
Comments
Post a Comment