Posted comments (9)

Posted by Ejavam07 at November 7, 2008 04:16:11 CET
Worked well for 1.2.15. Put the command line arg (-Dlog4j.debug=true) into the NetBeans IDE 6.1 and got the results through the output window while running in there.
Posted by Giri at May 19, 2009 16:20:51 CEST
Simply great example.Thank you very much.I appreciate your efforts.
Posted by Narayan at July 27, 2009 12:47:57 CEST
Nice, simple and easy

This is how tutorials ought to be
Posted by Amrutha at September 2, 2009 08:16:56 CEST
I got these errors while executing this tutorial program. kindly help.

D:\Java\jdk1.5.0_12\bin>java Log4jDemo

log4j:ERROR Could not instantiate class [org.apache.log4j.ConsoleAppender].
java.lang.ClassNotFoundException: org.apache.log4j.ConsoleAppender
at Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at org.apache.log4j.helpers.Loader.loadClass(
at org.apache.log4j.helpers.OptionConverter.instantiateByClassName(
at org.apache.log4j.helpers.OptionConverter.instantiateByKey(
at org.apache.log4j.PropertyConfigurator.parseAppender(
at org.apache.log4j.PropertyConfigurator.parseCategory(
at org.apache.log4j.PropertyConfigurator.configureRootCategory(
at org.apache.log4j.PropertyConfigurator.doConfigure(
at org.apache.log4j.PropertyConfigurator.doConfigure(
at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(
at org.apache.log4j.LogManager.<clinit>(
at org.apache.log4j.Logger.getLogger(
at Log4jDemo.<clinit>(
log4j:ERROR Could not instantiate appender named "stdout".
log4j:WARN No appenders could be found for logger (Log4jDemo.class).
log4j:WARN Please initialize the log4j system properly.
Posted by Ryan at May 13, 2010 16:36:10 CEST
Date projDate = new Date(Long.parseLong(project.getTimeStamp()));
StringBuffer dateStr = new StringBuffer();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
dateStr = sdf.format(projDate, dateStr, new FieldPosition(0));
String logFileName = logsDir + File.separator + project.getName() + "_" + dateStr.toString() + ".log";"\n**************Log file for this run: " + logFileName + "\n**************\n");

Logger rootLogger = Logger.getRootLogger();
Enumeration appenders = rootLogger.getAllAppenders();
FileAppender fa = null;
Appender currAppender = (Appender) appenders.nextElement();
if(currAppender instanceof FileAppender)
fa = (FileAppender) currAppender;
if(fa != null)
{"No File Appender found");

Posted by Kyrk at January 13, 2011 22:24:23 CET
Thanks a lot, very helpful.
Posted by Marias at January 24, 2011 22:57:09 CET
Where does one get the file: mentioned in this tutorial?
Posted by Robert Lie at January 25, 2011 05:38:47 CET
Marias, can be downloaded from:
Posted by Mani at November 26, 2011 08:49:40 CET
Very simple and much comfortable to understand