Thursday, March 22, 2007

Using Apache Commons Logging and Log4j

It's as easy as this:
  1. Download the latest and the greatest from Log4J.
  2. Download the latest and the greatest from Apache Commons Logging.
  3. Add the libraries to the $CLASSPATH.
  4. Write a Log4J properties file called log4j.properties and place it in a directory in the $CLASSPATH.
  5. You can now start logging in a class simply obtaining a logger with:
    1. private static final Log log = LogFactory.getLog(YourClass.class);
  6. and using it:
    1. log.info("your logging comment");