Handler error in SLF4JBridgeHandler in tomcat logs
Asked Answered
M

1

5

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!

Macrobiotic answered 9/5, 2013 at 23:25 Comment(1)
Long time since then...but I think I had the same issue. My mistake was that I copied the extra jars in /lib instead of /bin. Make sure they are copied in /bin and setenv.sh is setting the proper CLASSPATH, as mentioned in the instructions. Now it works!Mamoun
T
3

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_HOME\bin\setenv.bat for Windows:

set CLASSPATH=%CATALINA_HOME%\bin\jul-to-slf4j-1.7.5.jar;^
%CATALINA_HOME%\bin\slf4j-api-1.7.5.jar
Taciturn answered 28/9, 2013 at 16:36 Comment(2)
on my ubuntu server, find / -name setenv.sh returned nothingSorcim
By default the setenv script file is absent. If you need one, you have to create it. The script is placed either into CATALINA_BASE/bin or into CATALINA_HOME/bin directory. For example, in my ubuntu script is in /usr/share/tomcat8/bin/setenv.sh.Taciturn

© 2022 - 2024 — McMap. All rights reserved.