基本上,我遵循https://www.anexinet.com/blog/java-web-app-logging-in-tomcat/将Webapp日志定向到单独的文件。
Tomcat版本是8.5.20,我正在使用java.util.logging,并且logging.properties文件是现成的,具有以下更改:
handlers = 1catalina.org.apache.juli.AsyncFileHandler, ..., 5company.org.apache.juli.AsyncFileHandler, org.apache.tomee.jul.formatter.AsyncConsoleHandler
.handlers = 1catalina.org.apache.juli.AsyncFileHandler
#removed org.apache.tomee.jul.formatter.AsyncConsoleHandler
company.handlers = 5company.org.apache.juli.AsyncFileHandler
5company.org.apache.juli.AsyncFileHandler.level = FINE
5company.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
5company.org.apache.juli.AsyncFileHandler.prefix = company
我可以在logs / company2018-12-06.log中看到新的日志文件,但是日志级别是INFO而不是FINE定义。我尝试过:
package company.web;
public class AbcBean implements java.io.Serializable {
public void init() {
Logger.getLogger("company.web.AbcBean").log(Level.FINE, "fine log");
Logger.getLogger("company.web.AbcBean").log(Level.INFO, "info log");
}
...
}
在日志文件中,我只能看到“信息日志”,而看不到“精细日志”。我错过了什么?