Hi Scott,

I presume you have already read the link provided in the error:

   http://logback.qos.ch/codes.html#renamingError

Which applications write to apache-tomcat-6.0.24\logs\debug.log? Does Tomcat write there too?

Did you know that you can specify the context name in the logback configuration file? You can also have a configuraion file per application which than share a configuration file via inclusion.

Here is an example:

For application A:

<configuration>
  <statusListener
     class="ch.qos.logback.core.status.OnConsoleStatusListener" />
  <contextName>appA</contextName>
  <include file="c:/foo/shared-logback.xml"/>
</configuration>

For application B:

<configuration>
  <statusListener
     class="ch.qos.logback.core.status.OnConsoleStatusListener" />
  <contextName>appB</contextName>
  <include file="c:/foo/shared-logback.xml"/>
</configuration>

shared-logback.xml

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

     <rollingPolicy ....
 </appender>

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

HTH,
--
Ceki
http://twitter.com/#!/ceki

On 03/11/2011 5:47 PM, Scott Dudley wrote:

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.



_______________________________________________
Logback-user mailing list
[email protected]
http://mailman.qos.ch/mailman/listinfo/logback-user

Reply via email to