[logback-user] Log Rotation Fails on Windows if Using JNDI

Scott Dudley scott at telesoft.com
Thu Nov 3 17:47:36 CET 2011


I just discovered that log rotation fails on Windows if using 
ContextJNDISelector.  I've tried both FixedWindowRollingPolicy and 
TimeBasedRollingPolicy with the same outcome.  If I disable JNDI, I lose 
the contextName but rotation occurs as expected.

Here's the error I get:

12:22:36,006 |-INFO in c.q.l.co.rolling.helper.RenameUtil - Renaming 
file [c:\telmast6\soft\apache-tomcat-6.0.24\logs\debug.log] to 
[c:\telmast6\soft\apache-tomcat-6.0.24\logs\debug1.log]
12:22:36,006 |-WARN in c.q.l.co.rolling.helper.RenameUtil - Failed to 
rename file [c:\telmast6\soft\apache-tomcat-6.0.24\logs\debug.log] to 
[c:\telmast6\soft\apache-tomcat-6.0.24\logs\debug1.log].
12:22:36,006 |-WARN in c.q.l.co.rolling.helper.RenameUtil - Please 
consider leaving the [file] option of RollingFileAppender empty.
12:22:36,006 |-WARN in c.q.l.co.rolling.helper.RenameUtil - See also 
http://logback.qos.ch/codes.html#renamingError

And here is my logback.xml file:

<configuration scan="true" scanPeriod="30 seconds">

<appender name="FILE" 
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${catalina.home}/logs/debug.log</file>

<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${catalina.home}/logs/debug%i.log</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>5</maxIndex>
</rollingPolicy>

<triggeringPolicy 
class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>25MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{MM/dd 
HH:mm:ss.SSS}|%thread|%X{sessionUserName}|%-5level|%X{debugLevel}|%logger{36}|%replace(%msg){'\n', 
'~~~'}|%contextName%n</pattern>
</encoder>
</appender>

<root level="DEBUG">
<appender-ref ref="FILE" />
</root>

</configuration>

The logback and slf4j resources must be loaded by the servlet container 
classloader (multiple reasons) and this is also desirable as we want to 
funnel all logging into a single file however, we also need to know 
which application generated the call - er go our use of JNDI (MDC 
wouldn't work).

By the way, this is a Windows-only issue.  Works splendidly on Linux.

Thanks.


-- 
Scott Dudley
Senior Developer

Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016



More information about the Logback-user mailing list