logger.debug("The entry is {}.", entry);
//which expands effectively to
if (logger.isDebugEnabled()){
// Note that it's actually *more* efficient than this - see Huxi's comment below...
logger.debug("The entry is " + entry + ".");
}
因为它比 log4j 更新,所以它支持参数化日志记录,因为它直接实现了 SLF4j
SLF4j/Logback,因为它是由写 log4j 的同一个人写的,所以他把它做得更好(根据 Ken G-谢谢。看到 他们之前的新闻时,似乎很合适)
In our company project we use LOG4j and it is very easy to use like Stephen showed in his example.
我们还为 LOG4j 编写了自己的模式类,以便您可以创建自己的输出文件模式。您可以描述日志文件的外观。可以增强原始的 log4j 类。
All LOG4j properties you can change in a log4j.properties file, so you can use different files for different projects.
The 记录概述 gives the reason for its existence: logging from library code, when you have no control over the underlying logging framework. Very important for the various Apache projects, which will be linked into outside applications. Perhaps not so important for internal IT projects, where you have complete control.