logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacob Kjome" <h...@visi.com>
Subject Re: slf4j, log4j and PropertyConfigurator.configure
Date Thu, 07 Jun 2012 03:48:06 GMT

Do you have multiple copies of log4j.jar in different classloaders?  For 
instance, let's say you run under Tomcat where webapps use child-first 
classloading.  You place log4j and slf4j in WEB-INF/lib and configure Log4j 
for this classloader.  But then you also have log4j/slf4j in a parent 
classloader which didn't get configured and the code performing logging is 
also part of the parent classloader, not the webapp classloader.  In this 
case, the "no appenders could be found" message makes sense.

I'm not saying the above is exactly your situation, but possibly some 
derivation of it.

Jake

On Wed, 6 Jun 2012 18:26:51 -0400
 Jeff Sawatzky <jeff.sawatzky@locationary.com> wrote:
> I have a project where I am using slf4j with the log4j binder, and I am 
>trying to configure log4j with the PropertyConfigurator.  The project allows 
>for a common log4.properties file and a machine log4j.properties file, and at 
>start up I load the two files, combine them into a Properties object, and 
>then pass them to PropertyConfigurator.configure. But when I try to log using 
>slf4j I get a "log4j:WARN No appenders could be found for logger" error on 
>the class I am trying to log from.
> 
> In my app startup I have..
> 
> Properties props = //do work.......
> LogManager.resetConfiguration();
> PropertyConfigurator.configure(props);
> 
> but here is the output (with log4j.debug turned on)
> log4j: Parsing for [root] with value=[INFO, stdout].
> log4j: Level token is [INFO].
> log4j: Category root set to INFO
> log4j: Parsing appender named "stdout".
> log4j: Parsing layout options for "stdout".
> log4j: Setting property [conversionPattern] to [%-4r [%t] %-5p %c %x - 
>%m%n].
> log4j: End of parsing for "stdout".
> log4j: Parsed "stdout" options.
> log4j: Finished configuring.
> log4j: Parsing for [root] with value=[INFO].
> log4j: Level token is [INFO].
> log4j: Category root set to INFO
> log4j: Finished configuring.
> log4j:WARN No appenders could be found for logger 
>(com.loca.util.services.AppListener).
> log4j:WARN Please initialize the log4j system properly.
> log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for 
>more info.
> 
> Shouldn't the logger for com.loca.util.services.AppListener use the root 
>appender that was configured?
> 
> Thanks!


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message