Subject: How to disable FOP logging debug-messages




Hi,

we are using FOP 0.95 within a Java application to create PDF documents.

We are also using log4j in our Java application to print some debug and info
messages.

Unfortunately, if we set the loglevel to debug in the log4j configuration,
FOP automatically prints a lot of debug messages.

Is there a way to tell FOP not to create those debug messages?

This is the log4j configuration:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/";>
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">

</layout>
</appender>
<appender name="logfile" class="org.apache.log4j.FileAppender">


<layout class="org.apache.log4j.PatternLayout">

</layout>
</appender>
<root>
<!-- ALL | DEBUG | INFO | WARN | ERROR | FATAL | OFF -->
<priority value ="debug" />
<appender-ref ref="console" />
<appender-ref ref="logfile" />
</root>
</log4j:configuration>


And this is the Java application:

package com.ifm.Kanban;

import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;

import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;

import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.Fop;
import org.apache.fop.apps.FopFactory;
import org.apache.log4j.Logger;
import org.w3c.dom.Document;

public class CreateOutput {

public static final Logger logger =
Logger.getLogger(CreateOutput.class);

public static boolean createOutput(String stylesheet, String name,
String
type, Document dom, String outputDirectory) throws Exception {

// create output directory
File baseDir = new File(".");
File outDir = new File(baseDir, outputDirectory);
outDir.mkdirs();

// input and output files
File xsltfile = new File(baseDir, stylesheet+=".xsl");
logger.info("Using stylesheet file " + xsltfile.getAbsolutePath());
File pdffile = new File(outDir, name);
logger.info("Saving output file to " + pdffile.getAbsolutePath());

// construct a FopFactory and foUserAgent
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();

OutputStream out = new BufferedOutputStream(new
FileOutputStream(pdffile));

try {
// construct fop with desired output format
Fop fop = fopFactory.newFop(type, foUserAgent, out);

// setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new
StreamSource(xsltfile));

// TODO: necessary? Set the value of a in the stylesheet
transformer.setParameter("versionParam", "2.0");

// setup input for XSLT transformation
Source src = new DOMSource(dom);

// resulting SAX events (the generated FO) must be piped
through to
FOP
Result res = new SAXResult(fop.getDefaultHandler());

// start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
}

return true;

}

}


We already tried logger.setLevel(Level.OFF); just before the try-block but
FOP seems to ignore this setting.

These are some the debug-messages, FOP prints if we set the log4j level to
debug:

2009-02-16 10:14:04,807 DEBUG
[org.apache.fop.util.ContentHandlerFactoryRegistry] Dynamically adding
ContentHandlerFactory:
org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory
2009-02-16 10:14:04,807 DEBUG
[org.apache.fop.util.ContentHandlerFactoryRegistry] Dynamically adding
ContentHandlerFactory:
org.apache.fop.render.ps.extensions.PSExtensionHandlerFactory
2009-02-16 10:14:04,807 DEBUG
[org.apache.fop.util.ContentHandlerFactoryRegistry] Dynamically adding
ContentHandlerFactory:
org.apache.fop.fo.extensions.xmp.XMPContentHandlerFactory
2009-02-16 10:14:04,932 DEBUG
[org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry] Registered
org.apache.fop.image.loader.batik.PreloaderWMF with priority 1000
2009-02-16 10:14:04,932 DEBUG
[org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry] Registered
org.apache.fop.image.loader.batik.PreloaderSVG with priority 1000
2009-02-16 10:14:04,932 DEBUG
[org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry] Registered
org.apache.xmlgraphics.image.loader.impl.PreloaderTIFF with priority 1000
2009-02-16 10:14:04,932 DEBUG
[org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry] Registered
org.apache.xmlgraphics.image.loader.impl.PreloaderGIF with priority 1000
2009-02-16 10:14:04,932 DEBUG
[org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry] Registered
org.apache.xmlgraphics.image.loader.impl.PreloaderJPEG with priority 1000
2009-02-16 10:14:04,932 DEBUG
[org.apache.xmlgraphics.image.loader.spi.ImageImplRegistry] Registered
org.apache.xmlgraphics.image.loader.impl.PreloaderBMP with priority 1000
...

Thanks,
Frank
--
View this message in context:
http://www.nabble.com/How-to-disable-FOP-logging-debug-messages-tp22033935p22033935.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx
For additional commands, e-mail: fop-users-help@xxxxxxxxxxxxxxxxxxxxxx



Privacy