代码之家  ›  专栏  ›  技术社区  ›  Jules

用Tomcat 8.5/Eclipse 4.7/Java 8配置日志会导致启动失败[复制]

  •  0
  • Jules  · 技术社区  · 6 年前

    设置: eclipse juno r,tomcat 7.0.8,tomcat通过eclipse插件运行。 来自eclipse的tomcat启动配置具有vm参数 -djava.util.logging.config.file=“c:\ ws\serverlogs\tomcat7\conf\logging.properties” (参考文献: Where can I view Tomcat log files in Eclipse? ) 正在获取跟踪错误。

    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”和其他文件也有类似的错误。 我知道这些类来自tomcat-juli.jar at/bin。 我将这个jar添加到服务器类路径(eclipse->servers->open->open lauch configuration->classpath->user entries)中,但得到了相同的错误。 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 ,但我的问题似乎不同。

    编辑1 在服务器的vm参数中添加“-djava.util.logging.manager=org.apache.juli.classloaderLogManager”,并在logging.properties中将“\”改为“/”就成功了。 感谢Robin为Tomcat日志FAQ提供的指针

    谢谢您, VJ

    0 回复  |  直到 12 年前
        1
  •  16
  •   John McCarthy    12 年前

    确保设置了以下系统属性,

    -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
    

    如所见 here 在tomcat用户邮件列表中。

    我在发射Tomcat时遇到了同样的问题 YAJSW 而不是使用tomcat启动脚本。

        2
  •  0
  •   Robin    12 年前

    您可以查看此特定问题的常见问题解答: http://wiki.apache.org/tomcat/FAQ/Logging

    或者可以使用其他logging.properties,例如:

    log4j.rootLogger=DEBUG, A1
    log4j.appender.A1=org.apache.log4j.ConsoleAppender
    log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    
    # Print the date in ISO 8601 format
    log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
    
    # Print only messages of level WARN or above in the package com.foo.
    log4j.logger.com.foo=WARN