tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Hartung" <>
Subject Re: Setting up logging - Log4j
Date Wed, 12 Feb 2003 00:47:39 GMT
Log 4J isn't overly difficult.

Here's some tips:

Create a file. Here's a sample:
# Set root category priority to DEBUG and its only appender to A1.
log4j.rootCategory=DEBUG, A1

# Print only messages of priority INFO or above in the class

# A1 is set to be a FileAppender which outputs to System.out.

# A1 uses PatternLayout.
log4j.appender.A1.layout.ConversionPattern=%-8r %-5p %c - %m%n

Ensure that your file is in your classpath. For a WebApp,
you should put it into WEB-INF/classes.

To use the logger, here's a sample simple class:

import org.apache.log4j.Category;

public class ClassName
    /** The log4j Category for this class */
    private static final Category log =

    public void doSomething() {
        log.debug("Look, I'm doing something!");

The two components, the file, and the log.debug line are
the keys to basic Log4J functionality. tells what to log,
and where to log it. The log.debug tells at what level you want a particular
message to be logged.

Log4J has a lot more than this, but these two simple bits will take you a
log way.


Will Hartung

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message