Tomcat logging.properties 格式化程序未生效
Tomcat logging.properties formatter not taking effect
我正在尝试调整 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
有什么想法吗?
But I can't get to work formatter for the output
我假设您必须修改启动脚本 so the format property is present before the SimpleFormatter
class is loaded。
一旦 class 被加载,格式就永远被设置,所以如果 class 在读取日志属性之前被加载,您在文件中放置的内容将被忽略。
我正在尝试调整 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
有什么想法吗?
But I can't get to work formatter for the output
我假设您必须修改启动脚本 so the format property is present before the SimpleFormatter
class is loaded。
一旦 class 被加载,格式就永远被设置,所以如果 class 在读取日志属性之前被加载,您在文件中放置的内容将被忽略。