/** * Put this file, log4j.xml, and log4j.jar in a directory, X * * cd to X and compile this program. * * javac -d . -classpath log4j.jar:. Test.java * * Create a logs directory under X and run the program. * * java -cp log4j.jar:. com.zanthan.log4j.Test * * In the logs directory you'll find the debug.log, info.log, * warn.log, and error.log files. * */ package com.zanthan.log4j; import org.apache.log4j.Logger; public class Test { private static final Logger log = Logger.getLogger(Test.class); public static void testLogging() { if (log.isDebugEnabled()) log.debug("A Debug Message"); if (log.isInfoEnabled()) log.info("A Info Message"); log.warn("A Warn Message"); log.error("An Error Message"); } public static void main(String[] args) { testLogging(); } }