You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Klemens Muthmann <kl...@googlemail.com> on 2009/04/22 17:18:08 UTC
Properties for all but root logger ignored
Hi
I have written a java web application (and a batch application some
months in the past) and tried to use log4j to debug these applications.
It seems to work somehow but shows very strange behaviour as all logger
settings in log4j.properties except the rootLogger are ignored. This is
a problem because I can not just get the log messages for my classes but
have to go through thousands of messages produced by hibernate or
spring, etc. My log4j.properties file looks the following:
log4j.rootLogger=INFO,stdout
log4j.logger.de.myproject.controller=DEBUG,R
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L
- %m%n
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=C:/myproject.log
log4j.appender.R.MaxFileSize=100KB
# Keep one backup file
log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
The problem is that the second line is completely ignored. Does anyone
have a solution for this?
Regards
Klemens
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Properties for all but root logger ignored
Posted by Klemens Muthmann <kl...@googlemail.com>.
Thank you very much.
It seems to work now. I changed from log4j.properties to log4j.xml and
configured my logger (using commons-logging) like private static final
Log log = LogFactory(de.myproject.controller.MyClass.class) instead of
private static final Log log = LogFactory(MyClass.class).
Klemens
Jacob Kjome schrieb:
> First, I presume you named your loggers in the
> "de.myproject.controller" package based on the fully qualified class
> name, which is a common practice. If this is not true, please check
> the logger name you used.
>
> With that said, I suggest you set your rootLogger to a level of
> "WARN". This will automatically exclude all the hibernate, spring,
> and other library logging other than real problems. Then, for the
> cases you want more info, specify those loggers. I also suspect that
> you might not be using the config file you think you are using. Try
> running your app with -Dlog4j.debug=true to see what config file Log4j
> is loading. Note that it loads log4j.xml in preference to
> log4j.properties, so if log4j.xml is sitting in the root of the
> classpath, anywhere in the classpath, then it will be used instead of
> your log4j.properties file.
>
> Jake
>
>
> On Wed, 22 Apr 2009 17:18:08 +0200
> Klemens Muthmann <kl...@googlemail.com> wrote:
>> Hi
>>
>> I have written a java web application (and a batch application some
>> months in the past) and tried to use log4j to debug these
>> applications. It seems to work somehow but shows very strange
>> behaviour as all logger settings in log4j.properties except the
>> rootLogger are ignored. This is a problem because I can not just get
>> the log messages for my classes but have to go through thousands of
>> messages produced by hibernate or spring, etc. My log4j.properties
>> file looks the following:
>>
>> log4j.rootLogger=INFO,stdout
>> log4j.logger.de.myproject.controller=DEBUG,R
>>
>> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
>> log4j.appender.stdout.Target=System.out
>> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
>> log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p
>> %c{1}:%L - %m%n
>>
>> log4j.appender.R=org.apache.log4j.RollingFileAppender
>> log4j.appender.R.File=C:/myproject.log
>>
>> log4j.appender.R.MaxFileSize=100KB
>> # Keep one backup file
>> log4j.appender.R.MaxBackupIndex=1
>>
>> log4j.appender.R.layout=org.apache.log4j.PatternLayout
>> log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
>>
>> The problem is that the second line is completely ignored. Does
>> anyone have a solution for this?
>>
>> Regards
>> Klemens
>>
>>
>> ---------------------------------------------------------------------
>> 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
>
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Properties for all but root logger ignored
Posted by Jacob Kjome <ho...@visi.com>.
First, I presume you named your loggers in the "de.myproject.controller"
package based on the fully qualified class name, which is a common practice.
If this is not true, please check the logger name you used.
With that said, I suggest you set your rootLogger to a level of "WARN". This
will automatically exclude all the hibernate, spring, and other library
logging other than real problems. Then, for the cases you want more info,
specify those loggers. I also suspect that you might not be using the config
file you think you are using. Try running your app with -Dlog4j.debug=true to
see what config file Log4j is loading. Note that it loads log4j.xml in
preference to log4j.properties, so if log4j.xml is sitting in the root of the
classpath, anywhere in the classpath, then it will be used instead of your
log4j.properties file.
Jake
On Wed, 22 Apr 2009 17:18:08 +0200
Klemens Muthmann <kl...@googlemail.com> wrote:
> Hi
>
> I have written a java web application (and a batch application some months
>in the past) and tried to use log4j to debug these applications. It seems to
>work somehow but shows very strange behaviour as all logger settings in
>log4j.properties except the rootLogger are ignored. This is a problem because
>I can not just get the log messages for my classes but have to go through
>thousands of messages produced by hibernate or spring, etc. My
>log4j.properties file looks the following:
>
> log4j.rootLogger=INFO,stdout
> log4j.logger.de.myproject.controller=DEBUG,R
>
> log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> log4j.appender.stdout.Target=System.out
> log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L -
>%m%n
>
> log4j.appender.R=org.apache.log4j.RollingFileAppender
> log4j.appender.R.File=C:/myproject.log
>
> log4j.appender.R.MaxFileSize=100KB
> # Keep one backup file
> log4j.appender.R.MaxBackupIndex=1
>
> log4j.appender.R.layout=org.apache.log4j.PatternLayout
> log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
>
> The problem is that the second line is completely ignored. Does anyone have
>a solution for this?
>
> Regards
> Klemens
>
>
> ---------------------------------------------------------------------
> 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