Different level of logs in different log files

喜欢而已 提交于 2019-12-03 20:39:44

Finally got the answer by doing this i got the logs in different files.

<Loggers>
    <logger name="com.mvc.login" level="info" additivity="false">
        <AppenderRef ref="LoginController" level="error"/>
        <AppenderRef ref="InfoController" level="info"/>
    </logger>
  </Loggers>

Loggers must have unique names. The second logger in your config will replace the first one, which explains why you don't see any output for the appender referenced by the first logger.

Normally, a configuration has a root logger that will receive all events. I would recommend that, so that part of the config becomes:

<Loggers>
    <logger name="com.mvc.login" level="error" additivity="false">
        <AppenderRef ref="LoginController"/>
    </logger>
   <root level="trace">
        <AppenderRef ref="InfoController"/>
    </root>
</Loggers>
  <Filters>
    <ThresholdFilter level="warn" onMatch="DENY" onMismatch="ACCEPT" />
  </Filters>

This will print only Info log.If you assign level error then it will print only warn message etc.

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