logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Remko Popma <remko.po...@gmail.com>
Subject Re: log4j.properties gets loaded twice causing rollling to fail
Date Wed, 23 Jul 2014 14:45:56 GMT
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 <kcboyes@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.popma@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 <geraldlsg@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 yyyy-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 ['.'yyyy-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 ['.'yyyy-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 appenders
> > > .
> > > .
> > > 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".
> > > .
> > > .
> > > .
> > > log4j: Reading configuration from URL
> >
> file:/C:\Apache\Tomcat/webapps/mya/WEB-INF/classes/properties/log4j.properties
> > >
> > > log4j: Parsing for [org] with value=[INFO, DA, stdout].
> > > log4j: Level token is [INFO].
> > > log4j: Category org set to INFO
> > > log4j: Parsing appender named "DA".
> > > log4j: Parsing layout options for "DA".
> > > log4j: Setting property [conversionPattern] to [%-5p [%t] [%X{userID}]
> > %d{dd-MM-yyyy HH:mm:ss:SSS} [%30c{1}] - %m  %n].
> > > log4j: End of parsing for "DA".
> > > log4j: Setting property [append] to [true].
> > > log4j: Setting property [file] to [C:\Apache\Tomcat/logs/mya.log].
> > > log4j: Setting property [datePattern] to ['.'yyyy-MM-dd-HH].
> > > log4j: setFile called: C:\Apache\Tomcat/logs/mya.log, true
> > > log4j: setFile ended
> > > log4j: Appender [DA] to be rolled on top of every hour.
> > > log4j: Parsed "DA" options.
> > > log4j: Parsing appender named "stdout".
> > > log4j: Parsing layout options for "stdout".
> > > log4j: Setting property [conversionPattern] to [%-5p [%t] [%X{userID}]
> > %d{dd-MM-yyyy HH:mm:ss:SSS} [%30c{1}] - %m  %n].
> > > log4j: End of parsing for "stdout".
> > > log4j: Parsed "stdout" options.
> > > log4j: Handling log4j.additivity.org=[null]
> > > .
> > > .
> > > .
> > > #parsing of the application's log4j
> > > .
> > > .
> > > .
> > > log4j:ERROR Failed to rename [C:\Apache\Tomcat/logs/catalina] to
> > [C:\Apache\Tomcat/logs/catalina.2014-07-10-17-09-20.log].
> > > log4j:ERROR Failed to rename [C:\Apache\Tomcat/logs/localhost] to
> > [C:\Apache\Tomcat/logs/localhost.2014-07-10-17-09-20.log].
> > > log4j:ERROR Failed to rename [C:\Apache\Tomcat/logs/manager] to
> > [C:\Apache\Tomcat/logs/manager.2014-07-10-17-09-20.log].
> > > log4j:ERROR Failed to rename [C:\Apache\Tomcat/logs/host-manager] to
> > [C:\Apache\Tomcat/logs/host-manager.2014-07-10-17-09-20.log].
> > > log4j:ERROR Failed to rename [C:\Apache\Tomcat/logs/stdout] to
> > [C:\Apache\Tomcat/logs/stdout.2014-07-10-17-09-20.log].
> > > log4j:ERROR Failed to rename [C:\Apache\Tomcat/logs/stderr] to
> > [C:\Apache\Tomcat/logs/stderr.2014-07-10-17-09-20.log].
> > > ----------------------------------
> > >
> > >
> > > ----tomcat log4j properties----
> > >
> >
> log4j.rootLogger=INFO,CATALINA,LOCALHOST,MANAGER,HOST-MANAGER,stdout,stderr
> > >
> > > # Define all the appenders
> > > log4j.appender.CATALINA=org.apache.log4j.DailyRollingFileAppender
> > > log4j.appender.CATALINA.File=${catalina.base}/logs/catalina
> > > log4j.appender.CATALINA.Append=true
> > > log4j.appender.CATALINA.Encoding=UTF-8
> > > log4j.appender.CATALINA.DatePattern = '.'yyyy-MM-dd-HH-mm'.log'
> > > log4j.appender.CATALINA.layout = org.apache.log4j.PatternLayout
> > > log4j.appender.CATALINA.layout.ConversionPattern = %d [%t] %-5p %c-
> %m%n
> > >
> > > .
> > > .
> > > .
> > > log4j.appender.stdout=org.apache.log4j.DailyRollingFileAppender
> > > log4j.appender.stdout.File=${catalina.base}/logs/stdout
> > > log4j.appender.stdout.Append=true
> > > log4j.appender.stdout.Encoding=UTF-8
> > > log4j.appender.stdout.DatePattern = '.'yyyy-MM-dd-HH-mm'.log'
> > > log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
> > > log4j.appender.stdout.layout.ConversionPattern = %d [%t] %-5p %c- %m%n
> > >
> > >
> > > # Configure which loggers log to which appenders
> > >
> >
> log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost]=DEBUG,
> > CATALINA
> > >
> >
> log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[\manager]=DEBUG,
> > MANAGER
> > >
> >
> log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[\host-manager]=DEBUG,
> > HOST-MANAGER
> > >
> > > --------end tomcat log4j properties----
> > >
> > > ---my application's log4j---
> > > log4j.log.dir=${catalina.home}/logs
> > >
> > > #Application Log
> > > log4j.logger.ou.org.to=ALL, DA, stdout
> > > log4j.logger.aud=ALL,AudAppender, stdout
> > > log4j.logger.ou.org.to.osf.core.aop.MethodTrace=ALL,
> > MethodTraceAppender, stdout
> > > log4j.logger.ou.org.to.osf.core.aop.PerfMonitor=ALL, PerfAppender,
> stdout
> > >
> > > log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> > > log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> > > log4j.appender.stdout.layout.ConversionPattern=%-5p [%t] [%X{userID}]
> > %d{dd-MM-yyyy HH:mm:ss:SSS} [%30c{1}] - %m  %n
> > >
> > > log4j.appender.DA=org.apache.log4j.DailyRollingFileAppender
> > > log4j.appender.DA.file=${log4j.log.dir}/mya.log
> > > log4j.appender.DA.layout=org.apache.log4j.PatternLayout
> > > log4j.appender.DA.layout.ConversionPattern=%-5p [%t] [%X{userID}]
> > %d{dd-MM-yyyy HH:mm:ss:SSS} [%30c{1}] - %m  %n
> > > log4j.appender.DA.DatePattern='.'yyyy-MM-dd-HH
> > > log4j.appender.DA.append=true
> > > --------------------------------------
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > > For additional commands, e-mail: log4j-user-help@logging.apache.org
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> > For additional commands, e-mail: log4j-user-help@logging.apache.org
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message