Log Rotation Fails on Windows if Using JNDI

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

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.

There are two applications running under one Tomcat instance and yes, Tomcat also logs via the same file and configuration. Yes, I read the link in the error but there was nothing applicable to my specific configuration/scenario. Like I said, it does exactly what we want on Linux but log rotation fails on Windows. If I disable JNDI, log rotation works but then I lose context identification (application name) which is likewise critical. On 11/03/2011 11:06 AM, ceki wrote:
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,
-- Scott Dudley Senior Developer Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016 *o:* (602) 308-1115**| *f:* (602) 308-1300 | *w:* www.telesoft.com <http://www.telesoft.com> *TEM Edge Blog <http://www.telesoft.com/blog> *|*Twitter <http://www.twitter.com/_Telesoft> *|*Facebook <http://www.facebook.com/pages/Telesoft-Corp/76397971661>Join us at Telesoft Connections 2011. Learn more now! <http://www.telesoftconference.com>*

On 03/11/2011 7:39 PM, Scott Dudley wrote:
There are two applications running under one Tomcat instance and yes, Tomcat also logs via the same file and configuration.
Yes, I read the link in the error but there was nothing applicable to my specific configuration/scenario.
Like I said, it does exactly what we want on Linux but log rotation fails on Windows. If I disable JNDI, log rotation works but then I lose context identification (application name) which is likewise critical.
Linux is less picky about renaming files with open handles. However, this does not mean that your log files are not being clobbered under Linux. You should probably enable prudent mode [1]. It seems that you are ignoring my remarks about setting the context name within the config file. It's OK as ContextJNDISelector provides an alternative solution although ContextJNDISelector is an overkill if you are going to share the same configuration file. [1] http://logback.qos.ch/manual/appenders.html#prudent
On 11/03/2011 11:06 AM, ceki wrote:
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,
-- Scott Dudley Senior Developer
Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016
-- Ceki http://twitter.com/#!/ceki

I misunderstood Ceki. I thought that you were simply providing an alternative method of configuration via the separate files. If instead you mean that I can name the application's logging context that way without having to use ContextJNDISelector, then I'll give it a go and report back my results. Many thanks. On 11/03/2011 11:58 AM, ceki wrote:
On 03/11/2011 7:39 PM, Scott Dudley wrote:
There are two applications running under one Tomcat instance and yes, Tomcat also logs via the same file and configuration.
Yes, I read the link in the error but there was nothing applicable to my specific configuration/scenario.
Like I said, it does exactly what we want on Linux but log rotation fails on Windows. If I disable JNDI, log rotation works but then I lose context identification (application name) which is likewise critical.
Linux is less picky about renaming files with open handles. However, this does not mean that your log files are not being clobbered under Linux. You should probably enable prudent mode [1].
It seems that you are ignoring my remarks about setting the context name within the config file. It's OK as ContextJNDISelector provides an alternative solution although ContextJNDISelector is an overkill if you are going to share the same configuration file.
[1] http://logback.qos.ch/manual/appenders.html#prudent
On 11/03/2011 11:06 AM, ceki wrote:
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,
-- Scott Dudley Senior Developer
Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016
-- Scott Dudley Senior Developer Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016 *o:* (602) 308-1115**| *f:* (602) 308-1300 | *w:* www.telesoft.com <http://www.telesoft.com> *TEM Edge Blog <http://www.telesoft.com/blog> *|*Twitter <http://www.twitter.com/_Telesoft> *|*Facebook <http://www.facebook.com/pages/Telesoft-Corp/76397971661>Join us at Telesoft Connections 2011. Learn more now! <http://www.telesoftconference.com>*

Ceki, It looks like this will only work if each application loads it's own copy of the logback classes. If so, this is not the case. Like I said in my original post, we have to place them at the highest level classloader (Tomcat's lib) so there's only one. On 11/03/2011 11:58 AM, ceki wrote:
On 03/11/2011 7:39 PM, Scott Dudley wrote:
There are two applications running under one Tomcat instance and yes, Tomcat also logs via the same file and configuration.
Yes, I read the link in the error but there was nothing applicable to my specific configuration/scenario.
Like I said, it does exactly what we want on Linux but log rotation fails on Windows. If I disable JNDI, log rotation works but then I lose context identification (application name) which is likewise critical.
Linux is less picky about renaming files with open handles. However, this does not mean that your log files are not being clobbered under Linux. You should probably enable prudent mode [1].
It seems that you are ignoring my remarks about setting the context name within the config file. It's OK as ContextJNDISelector provides an alternative solution although ContextJNDISelector is an overkill if you are going to share the same configuration file.
[1] http://logback.qos.ch/manual/appenders.html#prudent
On 11/03/2011 11:06 AM, ceki wrote:
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,
-- Scott Dudley Senior Developer
Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016
-- Scott Dudley Senior Developer Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016 *o:* (602) 308-1115**| *f:* (602) 308-1300 | *w:* www.telesoft.com <http://www.telesoft.com> *TEM Edge Blog <http://www.telesoft.com/blog> *|*Twitter <http://www.twitter.com/_Telesoft> *|*Facebook <http://www.facebook.com/pages/Telesoft-Corp/76397971661>Join us at Telesoft Connections 2011. Learn more now! <http://www.telesoftconference.com>*

Sorry, I skipped the class loader part of the problem. In any case, you should really enable prudent mode if you don't want to have garbage in the shared log file. On 03/11/2011 9:16 PM, Scott Dudley wrote:
Ceki,
It looks like this will only work if each application loads it's own copy of the logback classes. If so, this is not the case. Like I said in my original post, we have to place them at the highest level classloader (Tomcat's lib) so there's only one.
On 11/03/2011 11:58 AM, ceki wrote:
On 03/11/2011 7:39 PM, Scott Dudley wrote:
There are two applications running under one Tomcat instance and yes, Tomcat also logs via the same file and configuration.
Yes, I read the link in the error but there was nothing applicable to my specific configuration/scenario.
Like I said, it does exactly what we want on Linux but log rotation fails on Windows. If I disable JNDI, log rotation works but then I lose context identification (application name) which is likewise critical.
Linux is less picky about renaming files with open handles. However, this does not mean that your log files are not being clobbered under Linux. You should probably enable prudent mode [1].
It seems that you are ignoring my remarks about setting the context name within the config file. It's OK as ContextJNDISelector provides an alternative solution although ContextJNDISelector is an overkill if you are going to share the same configuration file.
[1] http://logback.qos.ch/manual/appenders.html#prudent
On 11/03/2011 11:06 AM, ceki wrote:
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

My understanding from the documentation was that prudent was only relevant when multiple JVM's were writing to the same log. I have only one. I also read that it's use (although sometimes a necessity) incurs a 3X drop in speed. On 11/03/2011 01:29 PM, ceki wrote:
Sorry, I skipped the class loader part of the problem. In any case, you should really enable prudent mode if you don't want to have garbage in the shared log file.
On 03/11/2011 9:16 PM, Scott Dudley wrote:
Ceki,
It looks like this will only work if each application loads it's own copy of the logback classes. If so, this is not the case. Like I said in my original post, we have to place them at the highest level classloader (Tomcat's lib) so there's only one.
On 11/03/2011 11:58 AM, ceki wrote:
On 03/11/2011 7:39 PM, Scott Dudley wrote:
There are two applications running under one Tomcat instance and yes, Tomcat also logs via the same file and configuration.
Yes, I read the link in the error but there was nothing applicable to my specific configuration/scenario.
Like I said, it does exactly what we want on Linux but log rotation fails on Windows. If I disable JNDI, log rotation works but then I lose context identification (application name) which is likewise critical.
Linux is less picky about renaming files with open handles. However, this does not mean that your log files are not being clobbered under Linux. You should probably enable prudent mode [1].
It seems that you are ignoring my remarks about setting the context name within the config file. It's OK as ContextJNDISelector provides an alternative solution although ContextJNDISelector is an overkill if you are going to share the same configuration file.
[1] http://logback.qos.ch/manual/appenders.html#prudent
On 11/03/2011 11:06 AM, ceki wrote:
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,
-- Scott Dudley Senior Developer Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016 *o:* (602) 308-1115**| *f:* (602) 308-1300 | *w:* www.telesoft.com <http://www.telesoft.com> *TEM Edge Blog <http://www.telesoft.com/blog> *|*Twitter <http://www.twitter.com/_Telesoft> *|*Facebook <http://www.facebook.com/pages/Telesoft-Corp/76397971661>Join us at Telesoft Connections 2011. Learn more now! <http://www.telesoftconference.com>*

On 03/11/2011 9:37 PM, Scott Dudley wrote:
My understanding from the documentation was that prudent was only relevant when multiple JVM's were writing to the same log. I have only one. I also read that it's use (although sometimes a necessity) incurs a 3X drop in speed.
Multiple appenders writing to the same file (regardless of JVM) requires the prudent mode. -- Ceki http://twitter.com/#!/ceki

Understood. I have only one. Guess I'll have to unpack the source and roll up my sleeves. Thanks. On 11/03/2011 01:47 PM, ceki wrote:
On 03/11/2011 9:37 PM, Scott Dudley wrote:
My understanding from the documentation was that prudent was only relevant when multiple JVM's were writing to the same log. I have only one. I also read that it's use (although sometimes a necessity) incurs a 3X drop in speed.
Multiple appenders writing to the same file (regardless of JVM) requires the prudent mode.
-- Scott Dudley Senior Developer Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016 *o:* (602) 308-1115**| *f:* (602) 308-1300 | *w:* www.telesoft.com <http://www.telesoft.com> *TEM Edge Blog <http://www.telesoft.com/blog> *|*Twitter <http://www.twitter.com/_Telesoft> *|*Facebook <http://www.facebook.com/pages/Telesoft-Corp/76397971661>Join us at Telesoft Connections 2011. Learn more now! <http://www.telesoftconference.com>*

You have *multiple* appender instances (of the same type and run on the same JVM) writing to the same file - that requires the prudent mode. On 03/11/2011 9:52 PM, Scott Dudley wrote:
Understood. I have only one. Guess I'll have to unpack the source and roll up my sleeves. Thanks.
On 11/03/2011 01:47 PM, ceki wrote:
On 03/11/2011 9:37 PM, Scott Dudley wrote:
My understanding from the documentation was that prudent was only relevant when multiple JVM's were writing to the same log. I have only one. I also read that it's use (although sometimes a necessity) incurs a 3X drop in speed.
Multiple appenders writing to the same file (regardless of JVM) requires the prudent mode.

So clarify for me... If I have only one set of classes loaded by the servlet engine (Tomcat) and only one logback.xml file shared among all applications, how do I have multiple appenders? On 11/03/2011 01:57 PM, ceki wrote:
You have *multiple* appender instances (of the same type and run on the same JVM) writing to the same file - that requires the prudent mode.
On 03/11/2011 9:52 PM, Scott Dudley wrote:
Understood. I have only one. Guess I'll have to unpack the source and roll up my sleeves. Thanks.
On 11/03/2011 01:47 PM, ceki wrote:
On 03/11/2011 9:37 PM, Scott Dudley wrote:
My understanding from the documentation was that prudent was only relevant when multiple JVM's were writing to the same log. I have only one. I also read that it's use (although sometimes a necessity) incurs a 3X drop in speed.
Multiple appenders writing to the same file (regardless of JVM) requires the prudent mode.
_______________________________________________ Logback-user mailing list Logback-user@qos.ch http://mailman.qos.ch/mailman/listinfo/logback-user
-- Scott Dudley Senior Developer Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016 *o:* (602) 308-1115**| *f:* (602) 308-1300 | *w:* www.telesoft.com <http://www.telesoft.com> *TEM Edge Blog <http://www.telesoft.com/blog> *|*Twitter <http://www.twitter.com/_Telesoft> *|*Facebook <http://www.facebook.com/pages/Telesoft-Corp/76397971661>Join us at Telesoft Connections 2011. Learn more now! <http://www.telesoftconference.com>*

On 03/11/2011 10:02 PM, Scott Dudley wrote:
So clarify for me...
If I have only one set of classes loaded by the servlet engine (Tomcat) and only one logback.xml file shared among all applications, how do I have multiple appenders?
Sorry, you are right. If logback is loaded only once, then each appender mentioned in the config file will be loaded once. No need for prudent mode in this case. -- Ceki http://twitter.com/#!/ceki

On 03/11/2011 10:07 PM, ceki wrote:
On 03/11/2011 10:02 PM, Scott Dudley wrote:
So clarify for me...
If I have only one set of classes loaded by the servlet engine (Tomcat) and only one logback.xml file shared among all applications, how do I have multiple appenders?
Sorry, you are right. If logback is loaded only once, then each appender mentioned in the config file will be loaded once. No need for prudent mode in this case.
Stupid me. ContextJNDISelector will cause logback-classic to be loaded multiple times. If the logback-classic instances share the same config file, then you will have multiple appender instances writing to the same file => prudent mode needs to be enabled. -- Ceki http://twitter.com/#!/ceki

I'm using FixedWindowRollingPolicy and the doc says that prudent mode isn't supported with FixedWindowRollingPolicy (http://logback.qos.ch/manual/appenders.html#RollingFileAppender). On 11/03/2011 02:11 PM, ceki wrote:
On 03/11/2011 10:07 PM, ceki wrote:
On 03/11/2011 10:02 PM, Scott Dudley wrote:
So clarify for me...
If I have only one set of classes loaded by the servlet engine (Tomcat) and only one logback.xml file shared among all applications, how do I have multiple appenders?
Sorry, you are right. If logback is loaded only once, then each appender mentioned in the config file will be loaded once. No need for prudent mode in this case.
Stupid me. ContextJNDISelector will cause logback-classic to be loaded multiple times. If the logback-classic instances share the same config file, then you will have multiple appender instances writing to the same file => prudent mode needs to be enabled.
-- Scott Dudley Senior Developer Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016 *o:* (602) 308-1115**| *f:* (602) 308-1300 | *w:* www.telesoft.com <http://www.telesoft.com> *TEM Edge Blog <http://www.telesoft.com/blog> *|*Twitter <http://www.twitter.com/_Telesoft> *|*Facebook <http://www.facebook.com/pages/Telesoft-Corp/76397971661>Join us at Telesoft Connections 2011. Learn more now! <http://www.telesoftconference.com>*

If you have ContextJNDISelector as discussed previously, you must use prudent mode. With ContextJNDISelector , prudent mode is not optional but mandatory. You could abandon ContextJNDISelector and replace it with a servlet filter which inserts the name of the application into the MDC. An even better solution would be to write a custom converter, say JNDIPropertyConverter which would lookup the application name from JNDI and output the value found. See the docs on creating a custom converter [1] for details. From what we discussed thus far, I think JNDIPropertyConverter is your best bet yet. [1] http://logback.qos.ch/manual/layouts.html#customConversionSpecifier -- Ceki http://twitter.com/#!/ceki On 03/11/2011 10:23 PM, Scott Dudley wrote:
I'm using FixedWindowRollingPolicy and the doc says that prudent mode isn't supported with FixedWindowRollingPolicy (http://logback.qos.ch/manual/appenders.html#RollingFileAppender).
On 11/03/2011 02:11 PM, ceki wrote:
On 03/11/2011 10:07 PM, ceki wrote:
On 03/11/2011 10:02 PM, Scott Dudley wrote:
So clarify for me...
If I have only one set of classes loaded by the servlet engine (Tomcat) and only one logback.xml file shared among all applications, how do I have multiple appenders?
Sorry, you are right. If logback is loaded only once, then each appender mentioned in the config file will be loaded once. No need for prudent mode in this case.
Stupid me. ContextJNDISelector will cause logback-classic to be loaded multiple times. If the logback-classic instances share the same config file, then you will have multiple appender instances writing to the same file => prudent mode needs to be enabled.
-- Scott Dudley Senior Developer

Thanks for your time Ceki. It is very much appreciated. I'll try that and report back the results. On 11/04/2011 12:41 AM, ceki wrote:
If you have ContextJNDISelector as discussed previously, you must use prudent mode. With ContextJNDISelector , prudent mode is not optional but mandatory.
You could abandon ContextJNDISelector and replace it with a servlet filter which inserts the name of the application into the MDC. An even better solution would be to write a custom converter, say JNDIPropertyConverter which would lookup the application name from JNDI and output the value found. See the docs on creating a custom converter [1] for details. From what we discussed thus far, I think JNDIPropertyConverter is your best bet yet.
[1] http://logback.qos.ch/manual/layouts.html#customConversionSpecifier
-- Scott Dudley Senior Developer Telesoft Corp. | 1661 E. Camelback Rd., Suite 300 | Phoenix, AZ, 85016 *o:* (602) 308-1115**| *f:* (602) 308-1300 | *w:* www.telesoft.com <http://www.telesoft.com> *TEM Edge Blog <http://www.telesoft.com/blog> *|*Twitter <http://www.twitter.com/_Telesoft> *|*Facebook <http://www.facebook.com/pages/Telesoft-Corp/76397971661>Join us at Telesoft Connections 2011. Learn more now! <http://www.telesoftconference.com>*
participants (2)
-
ceki
-
Scott Dudley