[logback-dev] [JIRA] Commented: (LBCLASSIC-212) Logback classic doesn't work with Tomcat

Ron Koerner (JIRA) noreply-jira at qos.ch
Mon Nov 8 12:08:51 CET 2010


    [ http://jira.qos.ch/browse/LBCLASSIC-212?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11882#action_11882 ] 

Ron Koerner commented on LBCLASSIC-212:
---------------------------------------

Strangely, the problem is only there if all three components are there. If only two of {Netbeans, Tomcat, logback} are used in conjunction then it works fine.

To prove my assumption I looked a little bit harder into the docs and came up with this configuration file, which I assume is the same the BasicConfigurator would produce with the exception of the explicitely added %throwable:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>new %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n%throwable</pattern>
        </encoder>
    </appender>
    <root level="TRACE">
        <appender-ref ref="stdout"/>
    </root>
</configuration>

With this my webapp runs like a charm even in Netbeans.


> Logback classic doesn't work with Tomcat
> ----------------------------------------
>
>                 Key: LBCLASSIC-212
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-212
>             Project: logback-classic
>          Issue Type: Bug
>    Affects Versions: 0.9.21
>            Reporter: Grzegorz Borkowski
>            Assignee: Logback dev list
>            Priority: Critical
>         Attachments: Sample Maven Project.zip
>
>
> We have a web application running on Tomcat 6.0.26, which uses SLF4J for logging. Until now, we used SLF4J-Simple, and it worked very well. Now we try to switch to Logback, but we are not able to make it work. It works for logging one-line messages. But whenever any exception is thrown on server, which should print a stack trace, server hangs (It doesn't matter whether we actually print the stack trace in log or not). From what I was able to observe, it looks like it falls into endless loop, throwing "ClassNotFoundException: ch.qos.logback.classic.spi.ThrowableProxyUtil", which is caught and tried to be logged, which throws this exception again, and so on. I don't know why it throws this ClassNotFoundException - perhaps classloader issue? But even copying the logback jars to Tomcat's lib directory, I'm not able to run the application: than it has problems with starting up. Sometimes it freezes during loading web app, and often it helps to attach and detach debugger to Tomcat - it's a kind of magic... Anyway, it's horrendously painful, and I'm not able to make it work. Why such common setup (webapp on Tomcat) is not described in Logback documentation???
> This is our configuration file :
> <configuration scan="true">
>   <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
>     <!-- encoders are assigned the type
>          ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
>     <encoder>
>       <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n%ex</pattern>
>     </encoder>
>   </appender>
>   <root level="info">
>     <appender-ref ref="STDOUT" />
>   </root>
> </configuration>
>  (changing scan to "false" doesn't help. Also changing pattern  to  the one not containing "%ex" doesn't help)
> This is part of pom file related to logging:
>          <dependency>
>             <groupId>org.slf4j</groupId>
>             <artifactId>slf4j-api</artifactId>
>             <version>1.6.0</version>
>         </dependency>
>         <dependency>
>             <groupId>ch.qos.logback</groupId>
>             <artifactId>logback-classic</artifactId>
>             <version>0.9.21</version>
>             <scope>runtime</scope>
>         </dependency>
>         <!-- prevent JCL bundling into final WAR by using scope="provided" -->
>         <dependency>
>             <groupId>commons-logging</groupId>
>             <artifactId>commons-logging</artifactId>
>             <version>1.1.1</version>
>             <scope>provided</scope>
>         </dependency>
>         <!-- use this as adpater to satisfy dependencies on JCL -->
>         <dependency>
>             <groupId>org.slf4j</groupId>
>             <artifactId>jcl-over-slf4j</artifactId>
>             <version>1.6.0</version>
>         </dependency>
> If  we change dependency from logback to SLF4J simple (1.6.0) than everything works smoothly, stacktraces are printed to console, no freezing, everything is perfect.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       


More information about the logback-dev mailing list