Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
745 views
in Technique[技术] by (71.8m points)

logging - Handler error in SLF4JBridgeHandler in tomcat logs

My tomcat logs currently has a mix of log messages in different formats. So I am trying to set up SLF4J using JUL-to-SLF4J bridge.

I was initially getting log messages like

May 23, 2013 7:57:17 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
May 23, 2013 7:57:17 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.29
2013-05-23 19:57:47,224 [localhost-startStop-1] Loading XML bean definitions from class path resource [META-INF/cxf/cxf.xml]
2013-05-23 19:57:47,246 [localhost-startStop-1] Loading XML bean definitions from class path resource [META-INF/cxf/cxf-servlet.xml]

I followed a blog from here.. http://hwellmann.blogspot.com/2012/11/logging-with-slf4j-and-logback-in.html

Am using the following jars for SLF4J: jul-to-slf4j-1.7.5.jar, slf4j-api-1.7.5.jar

and in logging.properties

handlers = org.slf4j.bridge.SLF4JBridgeHandler

I am currently not getting mixed messages but on start of tomcat. It is not printing the tomcat format, but it throws Handler error

Below is a snippet of the logs

Handler error
java.lang.ClassNotFoundException: org.slf4j.bridge.SLF4JBridgeHandler
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:521)
    at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:464)
    at org.apache.juli.ClassLoaderLogManager.readConfiguration(ClassLoaderLogManager.java:288)
    at java.util.logging.LogManager$2.run(LogManager.java:278)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.logging.LogManager.readPrimordialConfiguration(LogManager.java:276)
    at java.util.logging.LogManager.getLogManager(LogManager.java:259)
    at java.util.logging.Logger.<init>(Logger.java:245)
    at java.util.logging.LogManager$RootLogger.<init>(LogManager.java:1104)
    at java.util.logging.LogManager$RootLogger.<init>(LogManager.java:1101)
    at java.util.logging.LogManager$1.run(LogManager.java:199)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.util.logging.LogManager.<clinit>(LogManager.java:176)
    at java.util.logging.Logger.getLogger(Logger.java:307)
    at com.sun.jmx.remote.util.ClassLogger.<init>(ClassLogger.java:55)
    at sun.management.jmxremote.ConnectorBootstrap.<clinit>(ConnectorBootstrap.java:739)
    at sun.management.Agent.startAgent(Agent.java:147)
    at sun.management.Agent.startAgent(Agent.java:289)
***startInternal() called
***startInternal() JoranConfigurator

I have been on this problem for days, tried a lot of combinations, but couldnt find any luck with it.

Thanks in Advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just create or edit CATALINA_HOME/bin/setenv.sh for Linux:

CLASSPATH=$CATALINA_HOME/bin/jul-to-slf4j-1.7.5.jar:  
$CATALINA_HOME/bin/slf4j-api-1.7.5.jar

or CATALINA_HOMEinsetenv.bat for Windows:

set CLASSPATH=%CATALINA_HOME%injul-to-slf4j-1.7.5.jar;^
%CATALINA_HOME%inslf4j-api-1.7.5.jar

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...