package embedding;
-//Java
+// Java
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
-
-//JAXP
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
-//FOP
+// FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
// Construct driver
Driver driver = new Driver();
- // Setup logger
- SimpleLog logger = new SimpleLog("log");
- logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
- driver.setLogger(logger);
+ // Setup driver
driver.initialize();
// Setup Renderer (output format)
package embedding;
-//Java
+// Java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-//SAX
+// SAX
import org.xml.sax.InputSource;
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
-//FOP
+// FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
// Construct driver
Driver driver = new Driver();
- // Setup logger
- SimpleLog logger = new SimpleLog("log");
- logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
- driver.setLogger(logger);
+ // Setup driver
driver.initialize();
// Setup Renderer (output format)
package embedding;
-//Java
+// Java
import java.io.File;
import java.io.OutputStream;
import java.io.IOException;
-//JAXP
+// JAXP
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXResult;
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
-//FOP
+// FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
-
import embedding.model.ProjectTeam;
/**
// Construct driver
Driver driver = new Driver();
- // Setup logger
- SimpleLog logger = new SimpleLog("log");
- logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
- driver.setLogger(logger);
+ // Setup driver
driver.initialize();
// Setup Renderer (output format)
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.sax.SAXResult;
-// Commons-Logging
-import org.apache.commons.logging.impl.SimpleLog;
-
//FOP
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
Driver driver = new Driver();
// Setup logger
- SimpleLog logger = new SimpleLog("log");
- logger.setLevel(SimpleLog.LOG_LEVEL_INFO);
- driver.setLogger(logger);
driver.initialize();
// Setup Renderer (output format)
<section id="basic-logging-new-version">
<title>Logging (Upcoming FOP 1.0 Version only)</title>
<p>
- You also need to set up logging. Global logging for all FOP
- processes is managed by MessageHandler. Per-instance logging
- is handled by Driver. You want to set both using an implementation
- of org.apache.commons.logging.Log. See
- <jump href="#logging">below</jump> for more information.
- </p>
- <p>
- Call <code>setLogger(Logger)</code> always immediately after
- instantiating the Driver object. See here:
+ Logging is handled automatically via Jakarta Commons-Logging, which uses
+ JDK logging by default. No special driver configuration is needed.
+ For specialized configuration of Commons-Logging (e.g. to use a
+ different logger or to change logging levels), please see the
+ <fork href="http://jakarta.apache.org/commons/logging/">Jakarta Commons-Logging</fork>
+ site.
</p>
- <source><![CDATA[
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.impl.SimpleLog;
-
-/*..*/
-
-Driver driver = new Driver();
-Log logger = new SimpleLog(SimpleLog.LOG_LEVEL_INFO);
-MessageHandler.setScreenLogger(logger);
-driver.setLogger(logger);]]></source>
</section>
<section id="render">
i = i + parseUnknownOption(args, i);
} else if (args[i].equals("-at")) {
i = i + parseAreaTreeOption(args, i);
+ } else if (args[i].equals("-v")) {
+ System.out.println("FOP Version " + Version.getVersion());
} else if (args[i].equals("-param")) {
if (i + 2 < args.length) {
if (xsltParams == null) {
+ " -x dump configuration settings \n"
+ " -c cfg.xml use additional configuration file cfg.xml\n"
+ " -l lang the language to use for user information \n"
- + " -s for area tree XML, down to block areas only\n\n"
+ + " -s for area tree XML, down to block areas only\n"
+ + " -v to show FOP version being used\n\n"
+ " [INPUT] \n"
+ " infile xsl:fo input file (the same as the next) \n"
+ " -fo infile xsl:fo input file \n"
/**
* shows the options for print output
*/
- public void printUsagePrintOutput() {
+ private void printUsagePrintOutput() {
System.err.println("USAGE: -print [-Dstart=i] [-Dend=i] [-Dcopies=i] [-Deven=true|false] "
+ " org.apache.fop.apps.Fop (..) -print \n"
+ "Example:\n"
+ "java -Dstart=1 -Dend=2 org.apache.Fop.apps.Fop infile.fo -print ");
}
-
/**
* Outputs all commandline settings
*/
package org.apache.fop.apps;
+// Java
+import java.io.IOException;
+import java.io.OutputStream;
+
+// XML
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.w3c.dom.Document;
+
// FOP
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FOTreeBuilder;
-
import org.apache.fop.fo.FOInputHandler;
import org.apache.fop.fo.FOTreeHandler;
import org.apache.fop.render.Renderer;
import org.apache.fop.tools.DocumentInputSource;
import org.apache.fop.tools.DocumentReader;
-import org.apache.commons.logging.impl.SimpleLog;
-import org.apache.commons.logging.Log;
-
-// XML
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.w3c.dom.Document;
-
-// Java
-import java.io.IOException;
-import java.io.OutputStream;
-
/**
* Primary class that drives overall FOP process.
* <P>
* <PRE>
* Driver driver = new Driver(new InputSource (args[0]),
* new FileOutputStream(args[1]));
- * driver.setLogger(myLogger); //optional
* driver.setRenderer(RENDER_PDF);
* driver.run();
* </PRE>
*
* <PRE>
* Driver driver = new Driver();
- * driver.setLogger(myLogger); //optional
* driver.setRenderer(new org.apache.fop.render.awt.AWTRenderer(translator));
* driver.render(parser, fileInputSource(args[0]));
* </PRE>
private XMLReader reader;
/**
- * the system resources that FOP will use
+ * The system resources that FOP will use
*/
- private Log log = null;
private FOUserAgent userAgent = null;
/**
return userAgent;
}
- /**
- * Provide the Driver instance with a logger.
- * @param log the logger. Must not be <code>null</code>.
- */
- public void setLogger(Log log) {
- if (this.log == null) {
- this.log = log;
- } else {
- getLogger().warn("Logger is already set! Won't use the new logger.");
- }
- }
-
-
- /**
- * Returns the logger for use by FOP.
- * @return the logger
- */
- public Log getLogger() {
- if (this.log == null) {
- // use SimpleLog as default when logger not explicitly set
- log = new SimpleLog("FOP");
- ((SimpleLog) log).setLevel(SimpleLog.LOG_LEVEL_INFO);
- }
-
- return this.log;
- }
-
/**
* Resets the Driver so it can be reused. Property and element
* mappings are reset to defaults.
/**
* Set the Renderer to use.
- * @param renderer the renderer instance to use (Note: Logger must be set at this point)
+ * @param renderer the renderer instance to use
*/
public void setRenderer(Renderer renderer) {
// AWTStarter calls this function directly
render(reader, source);
}
}
-
}
import java.io.BufferedOutputStream;
import java.io.FileOutputStream;
-import org.apache.commons.logging.impl.SimpleLog;
-
// FOP
import org.apache.fop.render.awt.AWTRenderer;
Driver driver = new Driver();
options = new CommandLineOptions(args);
- driver.setLogger(options.getLogger());
- driver.getLogger().info(version);
-
inputHandler = options.getInputHandler();
try {
/**
* logging instance
*/
- protected static Log logger = LogFactory.getLog("Renderer");
+ protected static Log logger = LogFactory.getLog("FOP");
/**
* producer (usually "FOP")
Driver driver = new Driver(foFile, null);
AWTPrintRenderer renderer = new AWTPrintRenderer();
- driver.setLogger(log);
driver.setRenderer(renderer);
driver.run();
Driver driver = new Driver();
AWTPrintRenderer renderer = new AWTPrintRenderer();
- driver.setLogger(log);
driver.setRenderer(renderer);
driver.render(input.getParser(), input.getInputSource());
//Setup FOP
Driver driver = new Driver();
- driver.setLogger(this.log);
driver.setRenderer(Driver.RENDER_PDF);
driver.initialize();
try {
Driver driver = new Driver();
- driver.setLogger(getLogger());
FOUserAgent userAgent = new FOUserAgent();
userAgent.setBaseURL(this.baseURL);
driver.setUserAgent(userAgent);