Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-23 Thread Kevin Hale Boyes
Does log4j2 support configuration through property (.lcf) files?  I haven't
checked recently but I thought it only supported XML configuration.
Thanks,
Kevin


On 10 July 2014 21:49, Remko Popma remko.po...@gmail.com wrote:

 Hi,

 Is it possible for you to switch to log4j2? All our effort is currently
 focussed on log4j2.

 Best regards,
 Remko

 Sent from my iPhone

  On 2014/07/11, at 12:16, guowei gerald...@yahoo.com.sg wrote:
 
  Dear all,
 
  I am using log4j for tomcat internal logging and also application
 logging.
 
  I followed Tomcat's instruction to configure log4j rolling and I also
 have configured my application to have its own log4j rolling.
 
  log4j.jar is in both Tomcat's lib and web application's lib, each have
 their respective log4j.properties
 
  I enabled -Dlog4j.debug and I can see the sequence of the events
 
  1) log4j.properties for the tomcat gets loaded by Tomcat's
 StandardClassLoader
  2) the same log4j.properties for tomcat gets loaded by the Tomcat's
 WebappClassLoader
  3) application's log4j.properties is loaded
 
  Between 1) and 2) I can see the tomcat files being rolled ( I
 intentionally set DailyRollingAppender to -MM-dd-HH-mm and DEBUG level
 to make sure lots of things gets logged). Rolling was working well. Files
 were rolled on the minute
 
  However, when step 2) kicks in, the rolling of tomcat files failed.
  I reckon that the moment the the same log4j.properties is loaded, there
 is a conflict since the same appenders are referred twice.
  I am not certain has it anything to do with the tomcat's log4j
 configuration or appliation's log4j configuration. The Application's log
 files are rolled correctly.
  Would appreciate if anyone can enlighten me.
 
  -Dlog4j.debug output
  log4j: Trying to find [log4j.xml] using context classloader
 org.apache.catalina.loader.StandardClassLoader@1529d183.
  log4j: Trying to find [log4j.xml] using
 org.apache.catalina.loader.StandardClassLoader@1529d183 class loader.
  log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
  log4j: Trying to find [log4j.properties] using context classloader
 org.apache.catalina.loader.StandardClassLoader@1529d183.
  log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for
 automatic log4j configuration.
  log4j: Reading configuration from URL
 file:/C:\Apache\Tomcat/lib/log4j.properties
  log4j: Parsing for [root] with
 value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
  log4j: Level token is [WARN].
  log4j: Category root set to WARN
  log4j: Parsing appender named CATALINA.
  log4j: Parsing layout options for CATALINA.
  log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
  log4j: End of parsing for CATALINA.
  log4j: Setting property [encoding] to [UTF-8].
  log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
  log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
  log4j: Setting property [append] to [true].
  log4j: setFile called: C:\Apache\Tomcat/logs/catalina, true
  log4j: setFile ended
  log4j: Appender [CATALINA] to be rolled on top of every minute.
  log4j: Parsed CATALINA options.
  log4j: Handling
 log4j.additivity.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=[null]
  log4j: Finished configuring.
  .
  .
  #Parsing for rest of the file
  .
  .
  log4j: Parsing for
 [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager]]
 with value=[WARN, HOST-MANAGER].
  log4j: Level token is [WARN].
  log4j: Category
 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager]
 set to WARN
  log4j: Parsing appender named HOST-MANAGER.
 
 
  delegate: false
   repositories:
 /WEB-INF/classes/
  -- Parent Classloader:
  org.apache.catalina.loader.StandardClassLoader@6c79fa4f
  .
  log4j: Trying to find [log4j.xml] using WebappClassLoader
   context: /mya
   delegate: false
   repositories:
 /WEB-INF/classes/
  -- Parent Classloader:
  org.apache.catalina.loader.StandardClassLoader@6c79fa4f
  class loader.
  log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
  log4j: Trying to find [log4j.properties] using context classloader
 WebappClassLoader
   context: /mya
   delegate: false
   repositories:
 /WEB-INF/classes/
  -- Parent Classloader:
  org.apache.catalina.loader.StandardClassLoader@6c79fa4f
  .
  log4j: Using URL [file://C:\Apache\Tomcat/lib/log4j.properties] for
 automatic log4j configuration.
 
  log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for
 automatic log4j configuration.
  log4j: log4j: Parsing for [root] with
 value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
  log4j: Level token is [WARN].
  Reading configuration from URL
 file:/C:\Apache\Tomcat/lib/log4j.properties
 
  log4j: Category root set to WARN
  log4j: Parsing appender named CATALINA.
  log4j: Parsing layout options for CATALINA.
  log4j: Setting property 

Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-23 Thread Remko Popma
Kevin, currently log4j2 does not support configuration from a properties
file. Only xml and json formats are supported. I don't think anybody on the
team is jumping to implement a properties configuration, one of the reasons
being that the hierarchical nature of the configuration does not really
match the flat format of properties. So although it might happen I would
not expect this in the near future.
The log4j2 xml format is shorter and easier than the log4j-1.2 xml format,
though. Give it a try...


On Wed, Jul 23, 2014 at 11:39 PM, Kevin Hale Boyes kcbo...@gmail.com
wrote:

 Does log4j2 support configuration through property (.lcf) files?  I haven't
 checked recently but I thought it only supported XML configuration.
 Thanks,
 Kevin


 On 10 July 2014 21:49, Remko Popma remko.po...@gmail.com wrote:

  Hi,
 
  Is it possible for you to switch to log4j2? All our effort is currently
  focussed on log4j2.
 
  Best regards,
  Remko
 
  Sent from my iPhone
 
   On 2014/07/11, at 12:16, guowei gerald...@yahoo.com.sg wrote:
  
   Dear all,
  
   I am using log4j for tomcat internal logging and also application
  logging.
  
   I followed Tomcat's instruction to configure log4j rolling and I also
  have configured my application to have its own log4j rolling.
  
   log4j.jar is in both Tomcat's lib and web application's lib, each have
  their respective log4j.properties
  
   I enabled -Dlog4j.debug and I can see the sequence of the events
  
   1) log4j.properties for the tomcat gets loaded by Tomcat's
  StandardClassLoader
   2) the same log4j.properties for tomcat gets loaded by the Tomcat's
  WebappClassLoader
   3) application's log4j.properties is loaded
  
   Between 1) and 2) I can see the tomcat files being rolled ( I
  intentionally set DailyRollingAppender to -MM-dd-HH-mm and DEBUG
 level
  to make sure lots of things gets logged). Rolling was working well. Files
  were rolled on the minute
  
   However, when step 2) kicks in, the rolling of tomcat files failed.
   I reckon that the moment the the same log4j.properties is loaded, there
  is a conflict since the same appenders are referred twice.
   I am not certain has it anything to do with the tomcat's log4j
  configuration or appliation's log4j configuration. The Application's log
  files are rolled correctly.
   Would appreciate if anyone can enlighten me.
  
   -Dlog4j.debug output
   log4j: Trying to find [log4j.xml] using context classloader
  org.apache.catalina.loader.StandardClassLoader@1529d183.
   log4j: Trying to find [log4j.xml] using
  org.apache.catalina.loader.StandardClassLoader@1529d183 class loader.
   log4j: Trying to find [log4j.xml] using
 ClassLoader.getSystemResource().
   log4j: Trying to find [log4j.properties] using context classloader
  org.apache.catalina.loader.StandardClassLoader@1529d183.
   log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for
  automatic log4j configuration.
   log4j: Reading configuration from URL
  file:/C:\Apache\Tomcat/lib/log4j.properties
   log4j: Parsing for [root] with
  value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
   log4j: Level token is [WARN].
   log4j: Category root set to WARN
   log4j: Parsing appender named CATALINA.
   log4j: Parsing layout options for CATALINA.
   log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
   log4j: End of parsing for CATALINA.
   log4j: Setting property [encoding] to [UTF-8].
   log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
   log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
   log4j: Setting property [append] to [true].
   log4j: setFile called: C:\Apache\Tomcat/logs/catalina, true
   log4j: setFile ended
   log4j: Appender [CATALINA] to be rolled on top of every minute.
   log4j: Parsed CATALINA options.
   log4j: Handling
 
 log4j.additivity.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=[null]
   log4j: Finished configuring.
   .
   .
   #Parsing for rest of the file
   .
   .
   log4j: Parsing for
 
 [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager]]
  with value=[WARN, HOST-MANAGER].
   log4j: Level token is [WARN].
   log4j: Category
 
 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager]
  set to WARN
   log4j: Parsing appender named HOST-MANAGER.
  
  
   delegate: false
repositories:
  /WEB-INF/classes/
   -- Parent Classloader:
   org.apache.catalina.loader.StandardClassLoader@6c79fa4f
   .
   log4j: Trying to find [log4j.xml] using WebappClassLoader
context: /mya
delegate: false
repositories:
  /WEB-INF/classes/
   -- Parent Classloader:
   org.apache.catalina.loader.StandardClassLoader@6c79fa4f
   class loader.
   log4j: Trying to find [log4j.xml] using
 ClassLoader.getSystemResource().
   log4j: Trying to find [log4j.properties] using context classloader
  WebappClassLoader
context: /mya
delegate: false

Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-23 Thread Kevin Hale Boyes
On 23 July 2014 08:45, Remko Popma remko.po...@gmail.com wrote:

 The log4j2 xml format is shorter and easier than the log4j-1.2 xml format,
 though. Give it a try...


I didn't realize that.  I'd also forgotten that json formats were supported.
I'll have a look.  Thanks!


Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-23 Thread Matt Sicker
YAML is also supported!


On 23 July 2014 09:53, Kevin Hale Boyes kcbo...@gmail.com wrote:

 On 23 July 2014 08:45, Remko Popma remko.po...@gmail.com wrote:

  The log4j2 xml format is shorter and easier than the log4j-1.2 xml
 format,
  though. Give it a try...
 

 I didn't realize that.  I'd also forgotten that json formats were
 supported.
 I'll have a look.  Thanks!




-- 
Matt Sicker boa...@gmail.com


Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-14 Thread Jacob Kjome

No.  More likely, there some code in your app performing manual configuration.

Jake


On Sun, 13 Jul 2014 16:31:35 +0800
 Gerald gerald...@yahoo.com.sg wrote:
Hi 
so in my case, because log4j.properties was not found in my webapps 
WEB-INF/classes, the webapp classloader then went to look for the 
log4j.properties in my tomcat. this second reloading causes the rolling to 
fail. 

I see that subsequently the log4j.properties of my webapp (in 
WEB-INF/classes/properties) was loaded towards the end, so can I infer the 
following?


The webapp classloader first tries to load all config files in 
WEB-INF/classes,and because log4j properties was not found , then goes back 
to (re)load log4j.properties in the tomcat's lib and then comes back to 
WEB-INF/classes/* to load the remaining configs? and since the 
log4j.properties was found in WEB-INF/classes/properties it was eventually 
loaded.


Regards.


On Sun 13 Jul, 2014, at 12:24 pm, Jacob Kjome h...@visi.com wrote:


Because Log4j, by default, looks for config files in the default package. 
Furthermore, because of Tomcat's child-first classloading behavior, if you 
place log4j.properties in the default package of the webapp (WEB-INF/classes) 
it won't bother looking in the parent classloader since it will have already 
found the config file in the webapp classloader.


Note, however, that log4j.xml takes precedence over log4j.properties.  So, 
if you have log4j.xml in Tomcat's classpath (in the default package), then 
even if you have log4j.properties in the webapp classpath, it will use 
log4j.xml from the server classpath.  If that case, you'd need log4j.xml in 
the webapp's default package to override the server's log4j.xml.  Just 
thought I'd point that out.



Jake

On Sun, 13 Jul 2014 00:04:26 +0800
  Gerald gerald...@yahoo.com.sg wrote:
Hi Could I trouble you to explain further why putting the application 
log4j.properties in WEB-INF/classes, as opposed to 
WEB-INF/classes/properties, would prevent the webapp classloader from seeing 
the tomcat's log4j.properties?

Gerald

On 11 Jul, 2014, at 11:27 pm, Jacob Kjome h...@visi.com wrote:
Why don't you place your webapp's log4j.properties file in WEB-INF/classes 
instead of WEB-INF/classes/properties?  That way, the webapp classloader 
won't ever see the tomcat log4j.properties, thus no rolling file appender 
conflicts.

Jake
On Fri, 11 Jul 2014 11:16:41 +0800
   guowei gerald...@yahoo.com.sg wrote:

Dear all,
I am using log4j for tomcat internal logging and also application logging.
I followed Tomcat's instruction to configure log4j rolling and I also have 
configured my application to have its own log4j rolling.
log4j.jar is in both Tomcat's lib and web application's lib, each have their 
respective log4j.properties

I enabled -Dlog4j.debug and I can see the sequence of the events
1) log4j.properties for the tomcat gets loaded by Tomcat's 
StandardClassLoader
2) the same log4j.properties for tomcat gets loaded by the Tomcat's 
WebappClassLoader

3) application's log4j.properties is loaded
Between 1) and 2) I can see the tomcat files being rolled ( I intentionally 
set DailyRollingAppender to -MM-dd-HH-mm and DEBUG level to make sure 
lots of things gets logged). Rolling was working well. Files were rolled on 
the minute
However, when step 2) kicks in, the rolling of tomcat files failed. I reckon 
that the moment the the same log4j.properties is loaded, there is a conflict 
since the same appenders are referred twice.
I am not certain has it anything to do with the tomcat's log4j configuration 
or appliation's log4j configuration. The Application's log files are rolled 
correctly.

Would appreciate if anyone can enlighten me.
-Dlog4j.debug output
log4j: Trying to find [log4j.xml] using context classloader 
org.apache.catalina.loader.StandardClassLoader@1529d183.
log4j: Trying to find [log4j.xml] using 
org.apache.catalina.loader.StandardClassLoader@1529d183 class loader.

log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader 
org.apache.catalina.loader.StandardClassLoader@1529d183.
log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for automatic 
log4j configuration.
log4j: Reading configuration from URL 
file:/C:\Apache\Tomcat/lib/log4j.properties
log4j: Parsing for [root] with 
value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].

log4j: Level token is [WARN].
log4j: Category root set to WARN
log4j: Parsing appender named CATALINA.
log4j: Parsing layout options for CATALINA.
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
log4j: End of parsing for CATALINA.
log4j: Setting property [encoding] to [UTF-8].
log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
log4j: Setting property [append] to [true].
log4j: setFile called: C:\Apache\Tomcat/logs/catalina, true
log4j: 

Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-14 Thread Gerald
Hi Jake, 

Thank you for the inputs/ advise.
I will look into fixing it with your suggestions.

Dear all, 

also thank you for reading my earlier posts and suggestions.

 On 14 Jul, 2014, at 10:39 pm, Jacob Kjome h...@visi.com wrote:
 
 No.  More likely, there some code in your app performing manual configuration.
 
 Jake
 
 
 On Sun, 13 Jul 2014 16:31:35 +0800
  Gerald gerald...@yahoo.com.sg wrote:
 Hi so in my case, because log4j.properties was not found in my webapps 
 WEB-INF/classes, the webapp classloader then went to look for the 
 log4j.properties in my tomcat. this second reloading causes the rolling to 
 fail. I see that subsequently the log4j.properties of my webapp (in 
 WEB-INF/classes/properties) was loaded towards the end, so can I infer the 
 following?
 The webapp classloader first tries to load all config files in 
 WEB-INF/classes,and because log4j properties was not found , then goes back 
 to (re)load log4j.properties in the tomcat's lib and then comes back to 
 WEB-INF/classes/* to load the remaining configs? and since the 
 log4j.properties was found in WEB-INF/classes/properties it was eventually 
 loaded.
 Regards.
 On Sun 13 Jul, 2014, at 12:24 pm, Jacob Kjome h...@visi.com wrote:
 Because Log4j, by default, looks for config files in the default package. 
 Furthermore, because of Tomcat's child-first classloading behavior, if you 
 place log4j.properties in the default package of the webapp 
 (WEB-INF/classes) it won't bother looking in the parent classloader since 
 it will have already found the config file in the webapp classloader.
 Note, however, that log4j.xml takes precedence over log4j.properties.  So, 
 if you have log4j.xml in Tomcat's classpath (in the default package), then 
 even if you have log4j.properties in the webapp classpath, it will use 
 log4j.xml from the server classpath.  If that case, you'd need log4j.xml in 
 the webapp's default package to override the server's log4j.xml.  Just 
 thought I'd point that out.
 Jake
 On Sun, 13 Jul 2014 00:04:26 +0800
   Gerald gerald...@yahoo.com.sg wrote:
 Hi Could I trouble you to explain further why putting the application 
 log4j.properties in WEB-INF/classes, as opposed to 
 WEB-INF/classes/properties, would prevent the webapp classloader from 
 seeing the tomcat's log4j.properties?
 Gerald
 On 11 Jul, 2014, at 11:27 pm, Jacob Kjome h...@visi.com wrote:
 Why don't you place your webapp's log4j.properties file in 
 WEB-INF/classes instead of WEB-INF/classes/properties?  That way, the 
 webapp classloader won't ever see the tomcat log4j.properties, thus no 
 rolling file appender conflicts.
 Jake
 On Fri, 11 Jul 2014 11:16:41 +0800
guowei gerald...@yahoo.com.sg wrote:
 Dear all,
 I am using log4j for tomcat internal logging and also application 
 logging.
 I followed Tomcat's instruction to configure log4j rolling and I also 
 have configured my application to have its own log4j rolling.
 log4j.jar is in both Tomcat's lib and web application's lib, each have 
 their respective log4j.properties
 I enabled -Dlog4j.debug and I can see the sequence of the events
 1) log4j.properties for the tomcat gets loaded by Tomcat's 
 StandardClassLoader
 2) the same log4j.properties for tomcat gets loaded by the Tomcat's 
 WebappClassLoader
 3) application's log4j.properties is loaded
 Between 1) and 2) I can see the tomcat files being rolled ( I 
 intentionally set DailyRollingAppender to -MM-dd-HH-mm and DEBUG 
 level to make sure lots of things gets logged). Rolling was working 
 well. Files were rolled on the minute
 However, when step 2) kicks in, the rolling of tomcat files failed. I 
 reckon that the moment the the same log4j.properties is loaded, there is 
 a conflict since the same appenders are referred twice.
 I am not certain has it anything to do with the tomcat's log4j 
 configuration or appliation's log4j configuration. The Application's log 
 files are rolled correctly.
 Would appreciate if anyone can enlighten me.
 -Dlog4j.debug output
 log4j: Trying to find [log4j.xml] using context classloader 
 org.apache.catalina.loader.StandardClassLoader@1529d183.
 log4j: Trying to find [log4j.xml] using 
 org.apache.catalina.loader.StandardClassLoader@1529d183 class loader.
 log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
 log4j: Trying to find [log4j.properties] using context classloader 
 org.apache.catalina.loader.StandardClassLoader@1529d183.
 log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for 
 automatic log4j configuration.
 log4j: Reading configuration from URL 
 file:/C:\Apache\Tomcat/lib/log4j.properties
 log4j: Parsing for [root] with 
 value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
 log4j: Level token is [WARN].
 log4j: Category root set to WARN
 log4j: Parsing appender named CATALINA.
 log4j: Parsing layout options for CATALINA.
 log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
 log4j: End of parsing for CATALINA.
 

Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-13 Thread Gerald
Hi 
so in my case, because log4j.properties was not found in my webapps 
WEB-INF/classes, the webapp classloader then went to look for the 
log4j.properties in my tomcat. this second reloading causes the rolling to 
fail. 

I see that subsequently the log4j.properties of my webapp (in 
WEB-INF/classes/properties) was loaded towards the end, so can I infer the 
following?

The webapp classloader first tries to load all config files in 
WEB-INF/classes,and because log4j properties was not found , then goes back to 
(re)load log4j.properties in the tomcat's lib and then comes back to 
WEB-INF/classes/* to load the remaining configs? and since the log4j.properties 
was found in WEB-INF/classes/properties it was eventually loaded.

Regards.

 On Sun 13 Jul, 2014, at 12:24 pm, Jacob Kjome h...@visi.com wrote:
 
 
 Because Log4j, by default, looks for config files in the default package.  
 Furthermore, because of Tomcat's child-first classloading behavior, if you 
 place log4j.properties in the default package of the webapp (WEB-INF/classes) 
 it won't bother looking in the parent classloader since it will have already 
 found the config file in the webapp classloader.
 
 Note, however, that log4j.xml takes precedence over log4j.properties.  So, if 
 you have log4j.xml in Tomcat's classpath (in the default package), then even 
 if you have log4j.properties in the webapp classpath, it will use log4j.xml 
 from the server classpath.  If that case, you'd need log4j.xml in the 
 webapp's default package to override the server's log4j.xml.  Just thought 
 I'd point that out.
 
 
 Jake
 
 On Sun, 13 Jul 2014 00:04:26 +0800
  Gerald gerald...@yahoo.com.sg wrote:
 Hi Could I trouble you to explain further why putting the application 
 log4j.properties in WEB-INF/classes, as opposed to 
 WEB-INF/classes/properties, would prevent the webapp classloader from seeing 
 the tomcat's log4j.properties?
 Gerald
 On 11 Jul, 2014, at 11:27 pm, Jacob Kjome h...@visi.com wrote:
 Why don't you place your webapp's log4j.properties file in WEB-INF/classes 
 instead of WEB-INF/classes/properties?  That way, the webapp classloader 
 won't ever see the tomcat log4j.properties, thus no rolling file appender 
 conflicts.
 Jake
 On Fri, 11 Jul 2014 11:16:41 +0800
   guowei gerald...@yahoo.com.sg wrote:
 Dear all,
 I am using log4j for tomcat internal logging and also application logging.
 I followed Tomcat's instruction to configure log4j rolling and I also have 
 configured my application to have its own log4j rolling.
 log4j.jar is in both Tomcat's lib and web application's lib, each have 
 their respective log4j.properties
 I enabled -Dlog4j.debug and I can see the sequence of the events
 1) log4j.properties for the tomcat gets loaded by Tomcat's 
 StandardClassLoader
 2) the same log4j.properties for tomcat gets loaded by the Tomcat's 
 WebappClassLoader
 3) application's log4j.properties is loaded
 Between 1) and 2) I can see the tomcat files being rolled ( I 
 intentionally set DailyRollingAppender to -MM-dd-HH-mm and DEBUG level 
 to make sure lots of things gets logged). Rolling was working well. Files 
 were rolled on the minute
 However, when step 2) kicks in, the rolling of tomcat files failed. I 
 reckon that the moment the the same log4j.properties is loaded, there is a 
 conflict since the same appenders are referred twice.
 I am not certain has it anything to do with the tomcat's log4j 
 configuration or appliation's log4j configuration. The Application's log 
 files are rolled correctly.
 Would appreciate if anyone can enlighten me.
 -Dlog4j.debug output
 log4j: Trying to find [log4j.xml] using context classloader 
 org.apache.catalina.loader.StandardClassLoader@1529d183.
 log4j: Trying to find [log4j.xml] using 
 org.apache.catalina.loader.StandardClassLoader@1529d183 class loader.
 log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
 log4j: Trying to find [log4j.properties] using context classloader 
 org.apache.catalina.loader.StandardClassLoader@1529d183.
 log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for 
 automatic log4j configuration.
 log4j: Reading configuration from URL 
 file:/C:\Apache\Tomcat/lib/log4j.properties
 log4j: Parsing for [root] with 
 value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
 log4j: Level token is [WARN].
 log4j: Category root set to WARN
 log4j: Parsing appender named CATALINA.
 log4j: Parsing layout options for CATALINA.
 log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
 log4j: End of parsing for CATALINA.
 log4j: Setting property [encoding] to [UTF-8].
 log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
 log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
 log4j: Setting property [append] to [true].
 log4j: setFile called: C:\Apache\Tomcat/logs/catalina, true
 log4j: setFile ended
 log4j: Appender [CATALINA] to be rolled on top of every minute.
 log4j: Parsed 

Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-12 Thread Gerald
Hi 

Could I trouble you to explain further why putting the application 
log4j.properties in WEB-INF/classes, as opposed to WEB-INF/classes/properties, 
would prevent the webapp classloader from seeing the tomcat's log4j.properties?

Gerald

 On 11 Jul, 2014, at 11:27 pm, Jacob Kjome h...@visi.com wrote:
 
 
 Why don't you place your webapp's log4j.properties file in WEB-INF/classes 
 instead of WEB-INF/classes/properties?  That way, the webapp classloader 
 won't ever see the tomcat log4j.properties, thus no rolling file appender 
 conflicts.
 
 Jake
 
 On Fri, 11 Jul 2014 11:16:41 +0800
  guowei gerald...@yahoo.com.sg wrote:
 Dear all,
 I am using log4j for tomcat internal logging and also application logging.
 I followed Tomcat's instruction to configure log4j rolling and I also have 
 configured my application to have its own log4j rolling.
 log4j.jar is in both Tomcat's lib and web application's lib, each have their 
 respective log4j.properties
 I enabled -Dlog4j.debug and I can see the sequence of the events
 1) log4j.properties for the tomcat gets loaded by Tomcat's 
 StandardClassLoader
 2) the same log4j.properties for tomcat gets loaded by the Tomcat's 
 WebappClassLoader
 3) application's log4j.properties is loaded
 Between 1) and 2) I can see the tomcat files being rolled ( I intentionally 
 set DailyRollingAppender to -MM-dd-HH-mm and DEBUG level to make sure 
 lots of things gets logged). Rolling was working well. Files were rolled on 
 the minute
 However, when step 2) kicks in, the rolling of tomcat files failed. I reckon 
 that the moment the the same log4j.properties is loaded, there is a conflict 
 since the same appenders are referred twice.
 I am not certain has it anything to do with the tomcat's log4j configuration 
 or appliation's log4j configuration. The Application's log files are rolled 
 correctly.
 Would appreciate if anyone can enlighten me.
 -Dlog4j.debug output
 log4j: Trying to find [log4j.xml] using context classloader 
 org.apache.catalina.loader.StandardClassLoader@1529d183.
 log4j: Trying to find [log4j.xml] using 
 org.apache.catalina.loader.StandardClassLoader@1529d183 class loader.
 log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
 log4j: Trying to find [log4j.properties] using context classloader 
 org.apache.catalina.loader.StandardClassLoader@1529d183.
 log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for automatic 
 log4j configuration.
 log4j: Reading configuration from URL 
 file:/C:\Apache\Tomcat/lib/log4j.properties
 log4j: Parsing for [root] with 
 value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
 log4j: Level token is [WARN].
 log4j: Category root set to WARN
 log4j: Parsing appender named CATALINA.
 log4j: Parsing layout options for CATALINA.
 log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
 log4j: End of parsing for CATALINA.
 log4j: Setting property [encoding] to [UTF-8].
 log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
 log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
 log4j: Setting property [append] to [true].
 log4j: setFile called: C:\Apache\Tomcat/logs/catalina, true
 log4j: setFile ended
 log4j: Appender [CATALINA] to be rolled on top of every minute.
 log4j: Parsed CATALINA options.
 log4j: Handling 
 log4j.additivity.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=[null]
 log4j: Finished configuring.
 .
 .
 #Parsing for rest of the file
 .
 .
 log4j: Parsing for 
 [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager]]
  with value=[WARN, HOST-MANAGER].
 log4j: Level token is [WARN].
 log4j: Category 
 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager] 
 set to WARN
 log4j: Parsing appender named HOST-MANAGER.
 delegate: false
   repositories:
 /WEB-INF/classes/
 -- Parent Classloader:
 org.apache.catalina.loader.StandardClassLoader@6c79fa4f
 .
 log4j: Trying to find [log4j.xml] using WebappClassLoader
   context: /mya
   delegate: false
   repositories:
 /WEB-INF/classes/
 -- Parent Classloader:
 org.apache.catalina.loader.StandardClassLoader@6c79fa4f
 class loader.
 log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
 log4j: Trying to find [log4j.properties] using context classloader 
 WebappClassLoader
   context: /mya
   delegate: false
   repositories:
 /WEB-INF/classes/
 -- Parent Classloader:
 org.apache.catalina.loader.StandardClassLoader@6c79fa4f
 .
 log4j: Using URL [file://C:\Apache\Tomcat/lib/log4j.properties] for 
 automatic log4j configuration.
 log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for automatic 
 log4j configuration.
 log4j: log4j: Parsing for [root] with 
 value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
 log4j: Level token is [WARN].
 Reading configuration from URL file:/C:\Apache\Tomcat/lib/log4j.properties
 log4j: Category root 

Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-12 Thread Jacob Kjome


Because Log4j, by default, looks for config files in the default package.  
Furthermore, because of Tomcat's child-first classloading behavior, if you 
place log4j.properties in the default package of the webapp (WEB-INF/classes) 
it won't bother looking in the parent classloader since it will have already 
found the config file in the webapp classloader.


Note, however, that log4j.xml takes precedence over log4j.properties.  So, if 
you have log4j.xml in Tomcat's classpath (in the default package), then even 
if you have log4j.properties in the webapp classpath, it will use log4j.xml 
from the server classpath.  If that case, you'd need log4j.xml in the webapp's 
default package to override the server's log4j.xml.  Just thought I'd point 
that out.



Jake

On Sun, 13 Jul 2014 00:04:26 +0800
 Gerald gerald...@yahoo.com.sg wrote:
Hi 

Could I trouble you to explain further why putting the application 
log4j.properties in WEB-INF/classes, as opposed to 
WEB-INF/classes/properties, would prevent the webapp classloader from seeing 
the tomcat's log4j.properties?


Gerald


On 11 Jul, 2014, at 11:27 pm, Jacob Kjome h...@visi.com wrote:


Why don't you place your webapp's log4j.properties file in WEB-INF/classes 
instead of WEB-INF/classes/properties?  That way, the webapp classloader 
won't ever see the tomcat log4j.properties, thus no rolling file appender 
conflicts.


Jake

On Fri, 11 Jul 2014 11:16:41 +0800
  guowei gerald...@yahoo.com.sg wrote:

Dear all,
I am using log4j for tomcat internal logging and also application logging.
I followed Tomcat's instruction to configure log4j rolling and I also have 
configured my application to have its own log4j rolling.
log4j.jar is in both Tomcat's lib and web application's lib, each have their 
respective log4j.properties

I enabled -Dlog4j.debug and I can see the sequence of the events
1) log4j.properties for the tomcat gets loaded by Tomcat's 
StandardClassLoader
2) the same log4j.properties for tomcat gets loaded by the Tomcat's 
WebappClassLoader

3) application's log4j.properties is loaded
Between 1) and 2) I can see the tomcat files being rolled ( I intentionally 
set DailyRollingAppender to -MM-dd-HH-mm and DEBUG level to make sure 
lots of things gets logged). Rolling was working well. Files were rolled on 
the minute
However, when step 2) kicks in, the rolling of tomcat files failed. I reckon 
that the moment the the same log4j.properties is loaded, there is a conflict 
since the same appenders are referred twice.
I am not certain has it anything to do with the tomcat's log4j configuration 
or appliation's log4j configuration. The Application's log files are rolled 
correctly.

Would appreciate if anyone can enlighten me.
-Dlog4j.debug output
log4j: Trying to find [log4j.xml] using context classloader 
org.apache.catalina.loader.StandardClassLoader@1529d183.
log4j: Trying to find [log4j.xml] using 
org.apache.catalina.loader.StandardClassLoader@1529d183 class loader.

log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader 
org.apache.catalina.loader.StandardClassLoader@1529d183.
log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for automatic 
log4j configuration.
log4j: Reading configuration from URL 
file:/C:\Apache\Tomcat/lib/log4j.properties
log4j: Parsing for [root] with 
value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].

log4j: Level token is [WARN].
log4j: Category root set to WARN
log4j: Parsing appender named CATALINA.
log4j: Parsing layout options for CATALINA.
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
log4j: End of parsing for CATALINA.
log4j: Setting property [encoding] to [UTF-8].
log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
log4j: Setting property [append] to [true].
log4j: setFile called: C:\Apache\Tomcat/logs/catalina, true
log4j: setFile ended
log4j: Appender [CATALINA] to be rolled on top of every minute.
log4j: Parsed CATALINA options.
log4j: Handling 
log4j.additivity.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=[null]

log4j: Finished configuring.
.
.
#Parsing for rest of the file
.
.
log4j: Parsing for 
[org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager]] 
with value=[WARN, HOST-MANAGER].

log4j: Level token is [WARN].
log4j: Category 
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager] 
set to WARN

log4j: Parsing appender named HOST-MANAGER.
delegate: false
   repositories:
 /WEB-INF/classes/
-- Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6c79fa4f
.
log4j: Trying to find [log4j.xml] using WebappClassLoader
   context: /mya
   delegate: false
   repositories:
 /WEB-INF/classes/
-- Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6c79fa4f
class loader.

Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-11 Thread Jacob Kjome


Why don't you place your webapp's log4j.properties file in WEB-INF/classes 
instead of WEB-INF/classes/properties?  That way, the webapp classloader won't 
ever see the tomcat log4j.properties, thus no rolling file appender conflicts.


Jake

On Fri, 11 Jul 2014 11:16:41 +0800
 guowei gerald...@yahoo.com.sg wrote:

Dear all,

I am using log4j for tomcat internal logging and also application logging.

I followed Tomcat's instruction to configure log4j rolling and I also have 
configured my application to have its own log4j rolling.


log4j.jar is in both Tomcat's lib and web application's lib, each have their 
respective log4j.properties


I enabled -Dlog4j.debug and I can see the sequence of the events

1) log4j.properties for the tomcat gets loaded by Tomcat's 
StandardClassLoader
2) the same log4j.properties for tomcat gets loaded by the Tomcat's 
WebappClassLoader

3) application's log4j.properties is loaded

Between 1) and 2) I can see the tomcat files being rolled ( I intentionally 
set DailyRollingAppender to -MM-dd-HH-mm and DEBUG level to make sure 
lots of things gets logged). Rolling was working well. Files were rolled on 
the minute


However, when step 2) kicks in, the rolling of tomcat files failed. 
I reckon that the moment the the same log4j.properties is loaded, there is a 
conflict since the same appenders are referred twice.
I am not certain has it anything to do with the tomcat's log4j configuration 
or appliation's log4j configuration. The Application's log files are rolled 
correctly.

Would appreciate if anyone can enlighten me.

-Dlog4j.debug output
log4j: Trying to find [log4j.xml] using context classloader 
org.apache.catalina.loader.StandardClassLoader@1529d183.
log4j: Trying to find [log4j.xml] using 
org.apache.catalina.loader.StandardClassLoader@1529d183 class loader.

log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader 
org.apache.catalina.loader.StandardClassLoader@1529d183.
log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for automatic 
log4j configuration.
log4j: Reading configuration from URL 
file:/C:\Apache\Tomcat/lib/log4j.properties
log4j: Parsing for [root] with 
value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].

log4j: Level token is [WARN].
log4j: Category root set to WARN
log4j: Parsing appender named CATALINA.
log4j: Parsing layout options for CATALINA.
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
log4j: End of parsing for CATALINA.
log4j: Setting property [encoding] to [UTF-8].
log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
log4j: Setting property [append] to [true].
log4j: setFile called: C:\Apache\Tomcat/logs/catalina, true
log4j: setFile ended
log4j: Appender [CATALINA] to be rolled on top of every minute.
log4j: Parsed CATALINA options.
log4j: Handling 
log4j.additivity.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=[null]

log4j: Finished configuring.
.
.
#Parsing for rest of the file
.
.
log4j: Parsing for 
[org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager]] 
with value=[WARN, HOST-MANAGER].

log4j: Level token is [WARN].
log4j: Category 
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager] 
set to WARN

log4j: Parsing appender named HOST-MANAGER.


delegate: false
  repositories:
/WEB-INF/classes/
-- Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6c79fa4f
.
log4j: Trying to find [log4j.xml] using WebappClassLoader
  context: /mya
  delegate: false
  repositories:
/WEB-INF/classes/
-- Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6c79fa4f
class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader 
WebappClassLoader

  context: /mya
  delegate: false
  repositories:
/WEB-INF/classes/
-- Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6c79fa4f
.
log4j: Using URL [file://C:\Apache\Tomcat/lib/log4j.properties] for 
automatic log4j configuration.


log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for automatic 
log4j configuration.
log4j: log4j: Parsing for [root] with 
value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].

log4j: Level token is [WARN].
Reading configuration from URL file:/C:\Apache\Tomcat/lib/log4j.properties

log4j: Category root set to WARN
log4j: Parsing appender named CATALINA.
log4j: Parsing layout options for CATALINA.
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
log4j: End of parsing for CATALINA.
log4j: Setting property [encoding] to [UTF-8].
log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].

log4j.properties gets loaded twice causing rollling to fail

2014-07-10 Thread guowei
Dear all,

I am using log4j for tomcat internal logging and also application logging.

I followed Tomcat's instruction to configure log4j rolling and I also have 
configured my application to have its own log4j rolling.

log4j.jar is in both Tomcat's lib and web application's lib, each have their 
respective log4j.properties

I enabled -Dlog4j.debug and I can see the sequence of the events

1) log4j.properties for the tomcat gets loaded by Tomcat's StandardClassLoader
2) the same log4j.properties for tomcat gets loaded by the Tomcat's 
WebappClassLoader
3) application's log4j.properties is loaded

Between 1) and 2) I can see the tomcat files being rolled ( I intentionally set 
DailyRollingAppender to -MM-dd-HH-mm and DEBUG level to make sure lots of 
things gets logged). Rolling was working well. Files were rolled on the minute

However, when step 2) kicks in, the rolling of tomcat files failed. 
I reckon that the moment the the same log4j.properties is loaded, there is a 
conflict since the same appenders are referred twice.
I am not certain has it anything to do with the tomcat's log4j configuration or 
appliation's log4j configuration. The Application's log files are rolled 
correctly.
Would appreciate if anyone can enlighten me.

-Dlog4j.debug output
log4j: Trying to find [log4j.xml] using context classloader 
org.apache.catalina.loader.StandardClassLoader@1529d183.
log4j: Trying to find [log4j.xml] using 
org.apache.catalina.loader.StandardClassLoader@1529d183 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader 
org.apache.catalina.loader.StandardClassLoader@1529d183.
log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for automatic 
log4j configuration.
log4j: Reading configuration from URL 
file:/C:\Apache\Tomcat/lib/log4j.properties
log4j: Parsing for [root] with 
value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
log4j: Level token is [WARN].
log4j: Category root set to WARN
log4j: Parsing appender named CATALINA.
log4j: Parsing layout options for CATALINA.
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
log4j: End of parsing for CATALINA.
log4j: Setting property [encoding] to [UTF-8].
log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
log4j: Setting property [append] to [true].
log4j: setFile called: C:\Apache\Tomcat/logs/catalina, true
log4j: setFile ended
log4j: Appender [CATALINA] to be rolled on top of every minute.
log4j: Parsed CATALINA options.
log4j: Handling 
log4j.additivity.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=[null]
log4j: Finished configuring.
.
.
#Parsing for rest of the file
.
.
log4j: Parsing for 
[org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager]] 
with value=[WARN, HOST-MANAGER].
log4j: Level token is [WARN].
log4j: Category 
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager] 
set to WARN
log4j: Parsing appender named HOST-MANAGER.


delegate: false
  repositories:
/WEB-INF/classes/
-- Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6c79fa4f
.
log4j: Trying to find [log4j.xml] using WebappClassLoader
  context: /mya
  delegate: false
  repositories:
/WEB-INF/classes/
-- Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6c79fa4f
 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader 
WebappClassLoader
  context: /mya
  delegate: false
  repositories:
/WEB-INF/classes/
-- Parent Classloader:
org.apache.catalina.loader.StandardClassLoader@6c79fa4f
.
log4j: Using URL [file://C:\Apache\Tomcat/lib/log4j.properties] for automatic 
log4j configuration.

log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for automatic 
log4j configuration.
log4j: log4j: Parsing for [root] with 
value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
log4j: Level token is [WARN].
Reading configuration from URL file:/C:\Apache\Tomcat/lib/log4j.properties

log4j: Category root set to WARN
log4j: Parsing appender named CATALINA.
log4j: Parsing layout options for CATALINA.
log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
log4j: End of parsing for CATALINA.
log4j: Setting property [encoding] to [UTF-8].
log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
log4j: Setting property [append] to [true].
log4j: setFile called: C:\Apache\Tomcat/logs/catalina, true
log4j: setFile ended
log4j: Appender [CATALINA] to be rolled on top of every minute.
log4j: Parsed CATALINA options.
log4j: Handling 
log4j.additivity.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=[null]
log4j: 

Re: log4j.properties gets loaded twice causing rollling to fail

2014-07-10 Thread Remko Popma
Hi,

Is it possible for you to switch to log4j2? All our effort is currently 
focussed on log4j2. 

Best regards,
Remko

Sent from my iPhone

 On 2014/07/11, at 12:16, guowei gerald...@yahoo.com.sg wrote:
 
 Dear all,
 
 I am using log4j for tomcat internal logging and also application logging.
 
 I followed Tomcat's instruction to configure log4j rolling and I also have 
 configured my application to have its own log4j rolling.
 
 log4j.jar is in both Tomcat's lib and web application's lib, each have their 
 respective log4j.properties
 
 I enabled -Dlog4j.debug and I can see the sequence of the events
 
 1) log4j.properties for the tomcat gets loaded by Tomcat's StandardClassLoader
 2) the same log4j.properties for tomcat gets loaded by the Tomcat's 
 WebappClassLoader
 3) application's log4j.properties is loaded
 
 Between 1) and 2) I can see the tomcat files being rolled ( I intentionally 
 set DailyRollingAppender to -MM-dd-HH-mm and DEBUG level to make sure 
 lots of things gets logged). Rolling was working well. Files were rolled on 
 the minute
 
 However, when step 2) kicks in, the rolling of tomcat files failed. 
 I reckon that the moment the the same log4j.properties is loaded, there is a 
 conflict since the same appenders are referred twice.
 I am not certain has it anything to do with the tomcat's log4j configuration 
 or appliation's log4j configuration. The Application's log files are rolled 
 correctly.
 Would appreciate if anyone can enlighten me.
 
 -Dlog4j.debug output
 log4j: Trying to find [log4j.xml] using context classloader 
 org.apache.catalina.loader.StandardClassLoader@1529d183.
 log4j: Trying to find [log4j.xml] using 
 org.apache.catalina.loader.StandardClassLoader@1529d183 class loader.
 log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
 log4j: Trying to find [log4j.properties] using context classloader 
 org.apache.catalina.loader.StandardClassLoader@1529d183.
 log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for automatic 
 log4j configuration.
 log4j: Reading configuration from URL 
 file:/C:\Apache\Tomcat/lib/log4j.properties
 log4j: Parsing for [root] with 
 value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
 log4j: Level token is [WARN].
 log4j: Category root set to WARN
 log4j: Parsing appender named CATALINA.
 log4j: Parsing layout options for CATALINA.
 log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
 log4j: End of parsing for CATALINA.
 log4j: Setting property [encoding] to [UTF-8].
 log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
 log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
 log4j: Setting property [append] to [true].
 log4j: setFile called: C:\Apache\Tomcat/logs/catalina, true
 log4j: setFile ended
 log4j: Appender [CATALINA] to be rolled on top of every minute.
 log4j: Parsed CATALINA options.
 log4j: Handling 
 log4j.additivity.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=[null]
 log4j: Finished configuring.
 .
 .
 #Parsing for rest of the file
 .
 .
 log4j: Parsing for 
 [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager]]
  with value=[WARN, HOST-MANAGER].
 log4j: Level token is [WARN].
 log4j: Category 
 org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[host-manager] 
 set to WARN
 log4j: Parsing appender named HOST-MANAGER.
 
 
 delegate: false
  repositories:
/WEB-INF/classes/
 -- Parent Classloader:
 org.apache.catalina.loader.StandardClassLoader@6c79fa4f
 .
 log4j: Trying to find [log4j.xml] using WebappClassLoader
  context: /mya
  delegate: false
  repositories:
/WEB-INF/classes/
 -- Parent Classloader:
 org.apache.catalina.loader.StandardClassLoader@6c79fa4f
 class loader.
 log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
 log4j: Trying to find [log4j.properties] using context classloader 
 WebappClassLoader
  context: /mya
  delegate: false
  repositories:
/WEB-INF/classes/
 -- Parent Classloader:
 org.apache.catalina.loader.StandardClassLoader@6c79fa4f
 .
 log4j: Using URL [file://C:\Apache\Tomcat/lib/log4j.properties] for automatic 
 log4j configuration.
 
 log4j: Using URL [file:/C:\Apache\Tomcat/lib/log4j.properties] for automatic 
 log4j configuration.
 log4j: log4j: Parsing for [root] with 
 value=[WARN,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr].
 log4j: Level token is [WARN].
 Reading configuration from URL file:/C:\Apache\Tomcat/lib/log4j.properties
 
 log4j: Category root set to WARN
 log4j: Parsing appender named CATALINA.
 log4j: Parsing layout options for CATALINA.
 log4j: Setting property [conversionPattern] to [%d [%t] %-5p %c- %m%n].
 log4j: End of parsing for CATALINA.
 log4j: Setting property [encoding] to [UTF-8].
 log4j: Setting property [datePattern] to ['.'-MM-dd-HH-mm'.log'].
 log4j: Setting property [file] to [C:\Apache\Tomcat/logs/catalina].
 log4j: Setting