David,

If I move all of the logback, log4j, etc jars to tomcat/lib, then it fails to find the logback.xml in my conf/Catalina/localhost directory.

Jars involved:

jcl-over-slf4j-1.7.5.jar
jul-to-slf4j-1.7.5.jar
log4j-over-slf4j-1.7.5.jar
logback-access-1.0.13.jar
logback-classic-1.0.13.jar
logback-core-1.0.13.jar
slf4j-api-1.7.5.jar

I really want to keep the logback.xml config out of the war files.  Different deployments will have different logging strategies.  I also need separate logback.xml's per tomcat instance.  Where can I keep my config so that it can be seen when the logback jars are not in the wars?

Thanks,
-Chris



On Thu, Sep 19, 2013 at 3:53 AM, David Roussel <nabble@diroussel.xsmail.com> wrote:
Where is logback on the class path? If it is in the wars, try taking it out and putting it in the tomcat class path. 

David

On 18 Sep 2013, at 16:30, Christopher Holt <chris.holt@hcs.us.com> wrote:

Hello,

I have logback configured so that code bundled in 2 different war files under tomcat will write to the same log file which rolls daily.  It's also marked as prudent.  I believe my configuration follows the guidelines from (http://logback.qos.ch/manual/appenders.html#prudentWithRolling).  

<configuration>
  <appender name="A1" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <prudent>true</prudent>
    <encoder>
            <pattern>%d{dd-MM HH:mm:ss} [%t] %c %5p %m%n</pattern>
    </encoder>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
        <FileNamePattern>${catalina.base}/logs/myapp.%d{yyyy-MM-dd}.log</FileNamePattern>
        <MaxHistory>30</MaxHistory>
    </rollingPolicy>
  </appender>

  <root level="INFO">
    <appender-ref ref="A1"/>
  </root>
</configuration>

My problem is that I get lots of java.nio.channels.OverlappingFileLockException.
...
java.nio.channels.FileChannel.lock(FileChannel.java:860)
ch.qos.logback.core.FileAppender.safeWrite(FileAppender.java:187)
ch.qos.logback.core.FileAppender.writeOut(FileAppender.java:204)
ch.qos.logback.core.OutputStreamAppender.subAppend(OutputStreamAppender.java:212)
...

After reading the docs for OverlappingFileLockException, my hunch is that the 2 different loggers, loaded by different class loaders within the same JVM are both trying to lock the file, unbeknownst to each other.  This violates the rules for FileChannel.lock, which seem to ignore the issue of locks among multiple class loaders within 1 JVM.

Has anyone run into this issue before?  Is there a simple workaround that I'm not thinking of?

Thanks,
Chris

_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user

_______________________________________________
Logback-user mailing list
Logback-user@qos.ch
http://mailman.qos.ch/mailman/listinfo/logback-user