我正在尝试调整catalina的日志记录。我对Tomcat的logging.properties看起来像:
handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler
.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.FileHandler.prefix = my-catalina.
1catalina.org.apache.juli.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=tomcat: [%1$tc] %4$s: %2$s - %5$s %6$s%n
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler
但我无法为输出工作格式化工具:
1catalina.org.apache.juli.FileHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format=tomcat: [%1$tc] %4$s: %2$s - %5$s %6$s%n
我在my-catalina.2018-03-16.log
看到的内容如下:
Mar 16, 2018 9:41:11 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 585 ms
Mar 16, 2018 9:41:11 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Mar 16, 2018 9:41:11 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.22
对此有何看法?
答案 0 :(得分:1)
但我无法为输出工作格式化
我认为您必须修改启动脚本so the format property is present before the SimpleFormatter
class is loaded。
一旦加载了类,格式就会永远设置好,所以如果在读取日志记录属性之前加载了类,那么放置在文件中的内容将被忽略。