Customizing Log4J

Now that you've seen Log4J in action, you can examine some of the ways that it can be customized to offer you just the information that you need. Take a look at that mysterious log4j.properties file, shown in listing 7.12:

Listing 7.12. log4j.properties
# Set root category priority to DEBUG and its only appender to A1.
log4j.rootCategory=DEBUG, A1

# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender

# A1 uses PatternLayout.
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

Looking at the file contents, you can begin to see that Log4J is more than just a simple console logging library. Log4J organizes everything ...

Get MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.