设置: Eclipse Juno R,Tomcat 7.0.8,tomcat 通过 eclipse 插件运行。来自 eclipse 的 Tomcat 启动配置有 VM 参数 -Djava.util.logging.config.file="C:\WS\Serverlogs\tomcat7\conf\logging .properties”(参考:在哪里可以查看 Eclipse 中的 Tomcat 日志文件?)出现以下错误。
Can't load log handler "1catalina.org.apache.juli.FileHandler"
java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler
java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.util.logging.LogManager$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.logging.LogManager.loadLoggerHandlers(Unknown Source)
at java.util.logging.LogManager.addLogger(Unknown Source)
at java.util.logging.LogManager$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.logging.LogManager.<clinit>(Unknown Source)
at java.util.logging.Logger.getLogger(Unknown Source)
at org.apache.juli.logging.DirectJDKLog.<init>(DirectJDKLog.java:71)
at org.apache.juli.logging.DirectJDKLog.getInstance(DirectJDKLog.java:196)
at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:170)
at org.apache.juli.logging.LogFactory.getInstance(LogFactory.java:242)
at org.apache.juli.logging.LogFactory.getLog(LogFactory.java:293)
at org.apache.catalina.startup.Bootstrap.<clinit>(Bootstrap.java:57)
Can't load log handler "1catalina.org.apache.juli.FileHandler"
“1catalina.org.apache.juli.FileHandler”、“2localhost.org.apache.juli.FileHandler”等也有类似的错误。我知道这些类来自 /bin 的 tomcat-juli.jar。我将此 jar 添加到服务器类路径中(Eclipse -> 服务器 -> 打开 -> 打开启动配置 -> 类路径 -> 用户条目),但得到了同样的错误。logging.properties 的内容是:
handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = C:\WS\Serverlogs\tomcat7/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = C:\WS\Serverlogs\tomcat7/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = C:\WS\Serverlogs\tomcat7/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
4host-manager.org.apache.juli.FileHandler.level = FINE
4host-manager.org.apache.juli.FileHandler.directory = C:\WS\Serverlogs\tomcat7/logs
4host-manager.org.apache.juli.FileHandler.prefix = host-manager.
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
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
非常感谢任何输入/指导。找到了这些 How to configure Tomcat JULI logging to roll log files? Local Tomcat Environment Not Starting ,但我的问题似乎有所不同。
Edit1 将“-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager”添加到服务器的 VM 参数并在 logging.properties 中将“\”更改为“/”就可以了。感谢 Robin 提供指向 Tomcat Logging FAQ 的指针
谢谢你,VJ