This page shows how you set up logging in FOP via Log4J.

Introduction

Apache FOP version 0.90 and later use Apache Commons Logging as the logging API which allows logging to any logging backend (Log4J, JDK logging etc.). Please check the Commons Logging documentation and the documentation of your preferred logging backend for any details.

The following was tested with Log4J 1.2.15. The procedure may differ for other versions and only the approach with the properties file is shown. To configure Log4J with an XML, please see the Log4J documentation.

Step by step

1. Add Log4J to the classpath

If you add Log4J to FOP's classpath, Apache Commons Logging will automatically choose Log4J as its logging backend (if you've not specified any system properties to configure Commons Logging otherwise).

2. Create a logging configuration file

Here's an minimal example log4j.properties that logs to the console:

log4j.rootLogger = INFO, console

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

log4j.appender.console.layout = org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern = %d [%t] %-5p %c{1} - %m%n

# This sets all FOP logging to INFO. Only output from the renderers is logged on the DEBUG level.
log4j.logger.org.apache.fop = INFO
log4j.logger.org.apache.fop.render = DEBUG

3. Tell Log4J to use your configuration file

Set the following system property when you start the JVM:

-Dlog4j.configuration=file:///C:/Dev/FOP/log4j.properties

That's already it. If you want to do something more fancy, please check the Commons Logging documentation.

HowTo/SetupLog4JLogging (last edited 2010-04-09 13:02:57 by JeremiasMaerki)