3.3. Log4J
Prev | Chapter 3. Logging | Next

## 3.3. Log4J

When Apache Log4J jars are present, the Commons Logging package will use Log4J by default. In a standalone application, logging levels are controlled by a resource named `log4j.properties`, which should be available as a top-level resource (either at the top level of a jar file, or in the root of one of the `CLASSPATH` directories). When deploying to a web or EJB application server, Log4J configuration is often performed in a `log4j.xml` file instead of a properties file. For further details on configuring Log4J, please see the Log4J Manual. We present several example `log4j.properties` files below.

Example 3.1. Standard Logging

    log4j.rootCategory=WARN, console
    log4j.category.kodo.Tool=INFO
    log4j.category.kodo.Runtime=INFO
    log4j.category.kodo.DataCache=WARN
    log4j.category.kodo.MetaData=WARN
    log4j.category.kodo.Enhance=WARN
    log4j.category.kodo.Query=WARN
    log4j.category.kodo.jdbc.SQL=WARN
    log4j.category.kodo.jdbc.JDBC=WARN
    log4j.category.kodo.jdbc.Schema=WARN

    log4j.appender.console=org.apache.log4j.ConsoleAppender

Example 3.2. Quiet Logging

    log4j.rootCategory=ERROR, console
    log4j.category.kodo.Tool=ERROR
    log4j.category.kodo.Runtime=ERROR
    log4j.category.kodo.DataCache=ERROR
    log4j.category.kodo.MetaData=ERROR
    log4j.category.kodo.Enhance=ERROR
    log4j.category.kodo.Query=ERROR
    log4j.category.kodo.jdbc.SQL=ERROR
    log4j.category.kodo.jdbc.JDBC=ERROR
    log4j.category.kodo.jdbc.Schema=ERROR

    log4j.appender.console=org.apache.log4j.ConsoleAppender

Example 3.3. Verbose Logging

    log4j.rootCategory=TRACE, console
    log4j.category.kodo.Tool=TRACE
    log4j.category.kodo.Runtime=TRACE
    log4j.category.kodo.DataCache=TRACE
    log4j.category.kodo.MetaData=TRACE
    log4j.category.kodo.Enhance=TRACE
    log4j.category.kodo.Query=TRACE
    log4j.category.kodo.jdbc.SQL=TRACE
    log4j.category.kodo.jdbc.JDBC=TRACE
    log4j.category.kodo.jdbc.Schema=TRACE

    log4j.appender.console=org.apache.log4j.ConsoleAppender

Prev | Up | Next
3.2. Disabling Logging | Home | 3.4. JDK 1.4 java.util.logging