aspose file tools*
The moose likes Other Application Frameworks and the fly likes log4j:WARN No appenders could be found for logger (log4jexample.LogExample). Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "log4j:WARN No appenders could be found for logger (log4jexample.LogExample)." Watch "log4j:WARN No appenders could be found for logger (log4jexample.LogExample)." New topic
Author

log4j:WARN No appenders could be found for logger (log4jexample.LogExample).

Rahul B. Shah
Greenhorn

Joined: Jan 17, 2011
Posts: 24
Hello Everybody,
I am trying simple log4j example & getting following message

log4j:WARN No appenders could be found for logger (log4jexample.LogExample).
log4j:WARN Please initialize the log4j system properly.

Following is my code :

package log4jexample;

import java.util.Enumeration;
import java.util.Properties;
import org.apache.log4j.*;

public class LogExample {

static Logger log = Logger.getLogger(LogExample.class.getName());

public static void main(String args[]){

log.debug("Here is some DEBUG");
log.info("Here is some INFO");
log.warn("Here is some WARN");
log.error("Here is some ERROR");
log.fatal("Here is some FATAL");

new LogExample().init();

}

public void init(){

Properties prop = System.getProperties();
Enumeration enumm = prop.propertyNames();

log.info("***** System Environment As Seen By JAVA *****");
log.debug("***** Formate: PROPERTY = VALUE *****");

while(enumm.hasMoreElements()){

String key = (String)enumm.nextElement();
log.info(key +"=" + System.getProperty(key));
}
}
}

Following is my log4j.properties file

# Set root category priority to INFO and its only appender to CONSOLE.

log4j.rootLogger=debug, stdout
#log4j.rootCategory=DEBUG,LOGFILE

# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE

# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.Threshold=INFO
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=- %m%n

# LOGFILE is set to be a File appender using a PatternLayout.
#log4j.appender.LOGFILE=org.apache.log4j.FileAppender
#log4j.appender.LOGFILE.File=c:\\axis.log
#log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
#log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n


I am using Eclipse galileo & i have added log4j.jar in build path & log4j.properties file is present in src folder and once i build the project i can see properties file generating in bin folder where class files are also generated, but still i am getting above message .

Thank-You
Rahul Shah
Ifteqar Ahmed
Ranch Hand

Joined: May 02, 2011
Posts: 85

Hi Rahul,

Can you show me your log4j configuration file?
Rahul B. Shah
Greenhorn

Joined: Jan 17, 2011
Posts: 24
Hello Ifteqar,
Log4j configuration files means log4j.properties file ?
If yes then here it is :

# Set root category priority to INFO and its only appender to CONSOLE.

log4j.rootLogger=debug, stdout
#log4j.rootCategory=DEBUG,LOGFILE

# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE

# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
#log4j.appender.stdout.Threshold=INFO
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=- %m%n

# LOGFILE is set to be a File appender using a PatternLayout.
#log4j.appender.LOGFILE=org.apache.log4j.FileAppender
#log4j.appender.LOGFILE.File=c:\\axis.log
#log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
#log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

If log4j.properties is not the configuration file then could you guide which one is configuration file ?

Thanks,
Rahul
 
 
subject: log4j:WARN No appenders could be found for logger (log4jexample.LogExample).
 
Similar Threads
log4j configuration headaches on AIX
Need help with log4j logging tool to log into database
question on log4j and eclipse
how to consume a webservice using axis2
Logging with axis 1.4 and log4j.