且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Log4j:是否需要具有多个记录器对象才能创建多个日志文件?

更新时间:2023-01-10 16:28:47

Log4j不允许在多个文件之间拆分日志.基本思想是所有日志语句都被认为是相等的,应该被平等对待.

Log4j does not easily allow for splitting logs between multiple files. The basic idea is that all log statements are considered equal and should be treated equally.

如果您使用slf4j作为API,则可以轻松地将后端从log4j切换到具有SiftingAppender的logback来实现此目的.

If you were using slf4j as the API you could easily switch the backend from log4j to logback which has SiftingAppender for exactly this purpose.

http://logback.qos.ch/manual/loggingSeparation.html