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 Dimitri Pissarenko <di...@gmx.net> on 2003/11/12 16:22:43 UTC

Configuration error

Hello!

I'm getting the log4j error message

<error-message>
log4j:WARN No appenders could be found for logger (SomeClass).
log4j:WARN Please initialize the log4j system properly.
</error-message>

This happens in a test case, which has the following main function:

<code-snippet>
import junit.framework.TestSuite;

public class SomeTestSuite extends TestSuite {
	
	...
	public static void main(String[] args) {
	ConsoleAppender consoleAppender=null;
	
	consoleAppender=new ConsoleAppender();
	BasicConfigurator.configure();
	Logger.getRootLogger().addAppender(consoleAppender);

Logger.getLogger(SomeClass.class).addAppender(consoleAppender);
	
	junit.swingui.TestRunner.run(SomeTestSuite.class);
	}
	...
}
</code-snippet>

Why does this error occur despite that fact that I explicitly add 
an appender to the Logger of SomeClass?

How can solve this problem?

TIA

Dimitri Pissarenko

PS: I'm using log4j 1.2.8


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


Re: Configuration error

Posted by Paul Smith <pa...@lawlex.com.au>.
On Thu, 2003-11-13 at 02:22, Dimitri Pissarenko wrote:
> Hello!
> 
> I'm getting the log4j error message
> 
> <error-message>
> log4j:WARN No appenders could be found for logger (SomeClass).
> log4j:WARN Please initialize the log4j system properly.
> </error-message>
> 
> 

Most likely candidate is that some where in the Test case code/thread of
execution, that is re-initialising Log4j after your explicit init call,
but before the call to the Logger in question. 

cheers,

Paul

> This happens in a test case, which has the following main function:
> 
> <code-snippet>
> import junit.framework.TestSuite;
> 
> public class SomeTestSuite extends TestSuite {
> 	
> 	...
> 	public static void main(String[] args) {
> 	ConsoleAppender consoleAppender=null;
> 	
> 	consoleAppender=new ConsoleAppender();
> 	BasicConfigurator.configure();
> 	Logger.getRootLogger().addAppender(consoleAppender);
> 
> Logger.getLogger(SomeClass.class).addAppender(consoleAppender);
> 	
> 	junit.swingui.TestRunner.run(SomeTestSuite.class);
> 	}
> 	...
> }
> </code-snippet>
> 
> Why does this error occur despite that fact that I explicitly add 
> an appender to the Logger of SomeClass?
> 
> How can solve this problem?
> 
> TIA
> 
> Dimitri Pissarenko
> 
> PS: I'm using log4j 1.2.8
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org


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


Re: Configuration error

Posted by Paul Smith <pa...@lawlex.com.au>.
I was also thinking that you might consider putting a Log message
immediately following the BasicConfigurator.configure() call.  If you
receive this message to the console, then something else is re-initing
Log4j.

BTW, 2 things about your code:

* The BasicConfigurator will automatically add and configure a Console
appender, should be no need to add one yourself.

* Appenders have an activateOptions() method that should be called after
all setters properties have been set, if you create an appender
manually. 

cheers,

Paul

> public class SomeTestSuite extends TestSuite {
> 	
> 	...
> 	public static void main(String[] args) {
> 	ConsoleAppender consoleAppender=null;
> 	
> 	consoleAppender=new ConsoleAppender();
> 	BasicConfigurator.configure();
> 	Logger.getRootLogger().addAppender(consoleAppender);
> 
> Logger.getLogger(SomeClass.class).addAppender(consoleAppender);
> 	
> 	junit.swingui.TestRunner.run(SomeTestSuite.class);
> 	}
> 	...
> }
> </code-snippet>
> 
> Why does this error occur despite that fact that I explicitly add 
> an appender to the Logger of SomeClass?
> 
> How can solve this problem?
> 
> TIA
> 
> Dimitri Pissarenko
> 
> PS: I'm using log4j 1.2.8
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: log4j-user-help@jakarta.apache.org


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