• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

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

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 85
MySQL Database Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rahul,

Can you show me your log4j configuration file?
 
Rahul B. Shah
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Trust God, but always tether your camel... to this tiny ad.
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!