不同日志文件中不同级别的日志 [英] Different level of logs in different log files
本文介绍了不同日志文件中不同级别的日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何编写一个简单的log4j2.xml文件,将不同级别的日志记录到不同的文件中?
How can we write a simple log4j2.xml file with different levels of logs going into different files?
例如,我们有错误日志,我需要将所有错误日志消息推送到一个日志文件中,并将所有信息日志消息推送到另一个文件中.
For example we have error logs any info logs I need to push all error log messages into one log file and all info log messages into another file.
我想要InfoController.log文件中的信息消息和LoginController.log文件中的错误消息
I want that info message in InfoController.log file and error message in LoginController.log file
我该怎么办?
推荐答案
这样做最终得到了答案,我将日志保存在了不同的文件中.
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>
这篇关于不同日志文件中不同级别的日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文