List of usage examples for org.apache.commons.logging LogFactory getFactory
@Deprecated public static LogFactory getFactory()
From source file:org.apache.ambari.servicemonitor.unit.Log4JDiagTest.java
@Test public void testLog4J() throws Throwable { Log log = LogFactory.getLog(this.getClass()); URL log4jURL = log.getClass().getClassLoader().getResource("log4j.properties"); System.out.println("Log4J is at " + log4jURL); log.info("Log4J is at " + log4jURL); LogFactory factory = LogFactory.getFactory(); log.info("Commons logging factory is " + factory); }
From source file:org.apache.fop.cli.CommandLineOptions.java
/** * Construct a command line option object. */// w ww . j a v a2 s .co m public CommandLineOptions() { LogFactory logFactory = LogFactory.getFactory(); // Enable the simple command line logging when no other logger is // defined. if (System.getProperty("org.apache.commons.logging.Log") == null) { logFactory.setAttribute("org.apache.commons.logging.Log", CommandLineLogger.class.getName()); setLogLevel("info"); } log = LogFactory.getLog("FOP"); }
From source file:org.apache.fop.fonts.apps.AbstractFontReader.java
/** * Sets the logging level.//from ww w . j av a 2 s . com * @param level the logging level ("debug", "info", "error" etc., see Jakarta Commons Logging) */ protected static void setLogLevel(String level) { // Set the evel for future loggers. LogFactory.getFactory().setAttribute("level", level); if (log instanceof CommandLineLogger) { // Set the level for the logger creates already. ((CommandLineLogger) log).setLogLevel(level); } }
From source file:org.apache.fop.fonts.apps.PFMReader.java
/** * The main method for the PFM reader tool. * * @param args Command-line arguments: [options] metricfile.pfm xmlfile.xml * where options can be://from w w w . ja va 2 s .c om * -fn <fontname> * default is to use the fontname in the .pfm file, but you can override * that name to make sure that the embedded font is used instead of installed * fonts when viewing documents with Acrobat Reader. * -cn <classname> * default is to use the fontname * -ef <path to the Type1 .pfb fontfile> * will add the possibility to embed the font. When running fop, fop will look * for this file to embed it * -er <path to Type1 fontfile relative to org/apache/fop/render/pdf/fonts> * you can also include the fontfile in the fop.jar file when building fop. * You can use both -ef and -er. The file specified in -ef will be searched first, * then the -er file. */ public static void main(String[] args) { String embFile = null; String embResource = null; String className = null; String fontName = null; Map options = new java.util.HashMap(); String[] arguments = parseArguments(options, args); // Enable the simple command line logging when no other logger is // defined. LogFactory logFactory = LogFactory.getFactory(); if (System.getProperty("org.apache.commons.logging.Log") == null) { logFactory.setAttribute("org.apache.commons.logging.Log", CommandLineLogger.class.getName()); } determineLogLevel(options); PFMReader app = new PFMReader(); log.info("PFM Reader for Apache FOP " + Version.getVersion() + "\n"); if (options.get("-ef") != null) { embFile = (String) options.get("-ef"); } if (options.get("-er") != null) { embResource = (String) options.get("-er"); } if (options.get("-fn") != null) { fontName = (String) options.get("-fn"); } if (options.get("-cn") != null) { className = (String) options.get("-cn"); } if (arguments.length != 2 || options.get("-h") != null || options.get("-help") != null || options.get("--help") != null) { displayUsage(); } else { try { log.info("Parsing font..."); PFMFile pfm = app.loadPFM(arguments[0]); if (pfm != null) { app.preview(pfm); Document doc = app.constructFontXML(pfm, fontName, className, embResource, embFile); app.writeFontXML(doc, arguments[1]); } log.info("XML font metrics file successfullly created."); } catch (Exception e) { log.error("Error while building XML font metrics file", e); System.exit(-1); } } }
From source file:org.apache.fop.fonts.apps.TTFReader.java
/** * The main method for the TTFReader tool. * * @param args Command-line arguments: [options] fontfile.ttf xmlfile.xml * where options can be:/*from w w w . j a va 2s.c o m*/ * -fn <fontname> * default is to use the fontname in the .ttf file, but you can override * that name to make sure that the embedded font is used instead of installed * fonts when viewing documents with Acrobat Reader. * -cn <classname> * default is to use the fontname * -ef <path to the truetype fontfile> * will add the possibility to embed the font. When running fop, fop will look * for this file to embed it * -er <path to truetype fontfile relative to org/apache/fop/render/pdf/fonts> * you can also include the fontfile in the fop.jar file when building fop. * You can use both -ef and -er. The file specified in -ef will be searched first, * then the -er file. * -nocs * if complex script features are disabled */ public static void main(String[] args) { String embFile = null; String embResource = null; String className = null; String fontName = null; String ttcName = null; boolean isCid = true; Map options = new java.util.HashMap(); String[] arguments = parseArguments(options, args); // Enable the simple command line logging when no other logger is // defined. LogFactory logFactory = LogFactory.getFactory(); if (System.getProperty("org.apache.commons.logging.Log") == null) { logFactory.setAttribute("org.apache.commons.logging.Log", CommandLineLogger.class.getName()); } determineLogLevel(options); TTFReader app = new TTFReader(); log.info("TTF Reader for Apache FOP " + Version.getVersion() + "\n"); if (options.get("-enc") != null) { String enc = (String) options.get("-enc"); if ("ansi".equals(enc)) { isCid = false; } } if (options.get("-ttcname") != null) { ttcName = (String) options.get("-ttcname"); } if (options.get("-ef") != null) { embFile = (String) options.get("-ef"); } if (options.get("-er") != null) { embResource = (String) options.get("-er"); } if (options.get("-fn") != null) { fontName = (String) options.get("-fn"); } if (options.get("-cn") != null) { className = (String) options.get("-cn"); } boolean useKerning = true; boolean useAdvanced = true; if (options.get("-nocs") != null) { useAdvanced = false; } if (arguments.length != 2 || options.get("-h") != null || options.get("-help") != null || options.get("--help") != null) { displayUsage(); } else { try { log.info("Parsing font..."); TTFFile ttf = app.loadTTF(arguments[0], ttcName, useKerning, useAdvanced); if (ttf != null) { org.w3c.dom.Document doc = app.constructFontXML(ttf, fontName, className, embResource, embFile, isCid, ttcName); if (isCid) { log.info("Creating CID encoded metrics..."); } else { log.info("Creating WinAnsi encoded metrics..."); } if (doc != null) { app.writeFontXML(doc, arguments[1]); } if (ttf.isEmbeddable()) { log.info("This font contains no embedding license restrictions."); } else { log.info("** Note: This font contains license retrictions for\n" + " embedding. This font shouldn't be embedded."); } } log.info(""); log.info("XML font metrics file successfully created."); } catch (Exception e) { log.error("Error while building XML font metrics file.", e); System.exit(-1); } } }
From source file:org.apache.fop.fonts.apps.TTFReaderBBox.java
/** * The main method for the TTFReaderBBox tool. * * @param args Command-line arguments: [options] fontfile.ttf xmlfile.xml * where options can be:/*from w w w .j a v a 2 s .c om*/ * -fn <fontname> * default is to use the fontname in the .ttf file, but you can override * that name to make sure that the embedded font is used instead of installed * fonts when viewing documents with Acrobat Reader. * -cn <classname> * default is to use the fontname * -ef <path to the truetype fontfile> * will add the possibility to embed the font. When running fop, fop will look * for this file to embed it * -er <path to truetype fontfile relative to org/apache/fop/render/pdf/fonts> * you can also include the fontfile in the fop.jar file when building fop. * You can use both -ef and -er. The file specified in -ef will be searched first, * then the -er file. */ public static void main(String[] args) { String embFile = null; String embResource = null; String className = null; String fontName = null; String ttcName = null; boolean isCid = true; Map options = new java.util.HashMap(); String[] arguments = parseArguments(options, args); // Enable the simple command line logging when no other logger is // defined. LogFactory logFactory = LogFactory.getFactory(); if (System.getProperty("org.apache.commons.logging.Log") == null) { logFactory.setAttribute("org.apache.commons.logging.Log", CommandLineLogger.class.getName()); } determineLogLevel(options); TTFReaderBBox app = new TTFReaderBBox(); log.info("TTF Reader for Apache FOP " + Version.getVersion() + "\n"); if (options.get("-enc") != null) { String enc = (String) options.get("-enc"); if ("ansi".equals(enc)) { isCid = false; } } if (options.get("-ttcname") != null) { ttcName = (String) options.get("-ttcname"); } if (options.get("-ef") != null) { embFile = (String) options.get("-ef"); } if (options.get("-er") != null) { embResource = (String) options.get("-er"); } if (options.get("-fn") != null) { fontName = (String) options.get("-fn"); } if (options.get("-cn") != null) { className = (String) options.get("-cn"); } if (arguments.length != 2 || options.get("-h") != null || options.get("-help") != null || options.get("--help") != null) { displayUsage(); } else { try { log.info("Parsing font..."); TTFFile ttf = app.loadTTF(arguments[0], ttcName); if (ttf != null) { org.w3c.dom.Document doc = app.constructFontXML(ttf, fontName, className, embResource, embFile, isCid, ttcName); if (isCid) { log.info("Creating CID encoded metrics..."); } else { log.info("Creating WinAnsi encoded metrics..."); } if (doc != null) { app.writeFontXML(doc, arguments[1]); } if (ttf.isEmbeddable()) { log.info("This font contains no embedding license restrictions."); } else { log.info("** Note: This font contains license retrictions for\n" + " embedding. This font shouldn't be embedded."); } } log.info(""); log.info("XML font metrics file successfully created."); } catch (Exception e) { log.error("Error while building XML font metrics file.", e); System.exit(-1); } } }
From source file:org.apache.fop.util.CommandLineLogger.java
/** * Construct the logger with a default log level taken from the LogFactory * attribute "level"./* w w w .j a v a 2s .c o m*/ * @param logName the logger name. */ public CommandLineLogger(String logName) { this.logName = logName; setLogLevel((String) LogFactory.getFactory().getAttribute("level")); }
From source file:org.apache.ftpserver.FtpConfigImpl.java
/** * Constructor - set the root configuration. *//* w w w . j a va 2 s. c om*/ public FtpConfigImpl(Configuration conf) throws Exception { try { // get the log classes m_logFactory = LogFactory.getFactory(); m_logFactory = new FtpLogFactory(m_logFactory); m_log = m_logFactory.getInstance(FtpConfigImpl.class); // create all the components m_socketFactory = (ISocketFactory) createComponent(conf, "socket-factory", "org.apache.ftpserver.socketfactory.FtpSocketFactory"); m_dataConConfig = (IDataConnectionConfig) createComponent(conf, "data-connection", "org.apache.ftpserver.DataConnectionConfig"); m_messageResource = (IMessageResource) createComponent(conf, "message", "org.apache.ftpserver.message.MessageResourceImpl"); m_connectionManager = (IConnectionManager) createComponent(conf, "connection-manager", "org.apache.ftpserver.ConnectionManagerImpl"); m_ipRestrictor = (IIpRestrictor) createComponent(conf, "ip-restrictor", "org.apache.ftpserver.iprestrictor.FileIpRestrictor"); m_userManager = (UserManager) createComponent(conf, "user-manager", "org.apache.ftpserver.usermanager.PropertiesUserManager"); m_fileSystemManager = (FileSystemManager) createComponent(conf, "file-system-manager", "org.apache.ftpserver.filesystem.NativeFileSystemManager"); m_statistics = (IFtpStatistics) createComponent(conf, "statistics", "org.apache.ftpserver.FtpStatisticsImpl"); // create user if necessary boolean userCreate = conf.getBoolean("create-default-user", true); if (userCreate) { createDefaultUsers(); } // create and initialize ftlets m_ftpletContainer = new FtpletContainer(); String ftpletNames = conf.getString("ftplets", null); Configuration ftpletConf = conf.getConfiguration("ftplet", EmptyConfiguration.INSTANCE); m_ftpletContainer.init(this, ftpletNames, ftpletConf); } catch (Exception ex) { dispose(); throw ex; } }
From source file:org.apache.ftpserver.socketfactory.FtpSocketFactoryTest.java
public void testSetLogFactory() { ftpSocketFactory.setLogFactory(LogFactory.getFactory()); ftpSocketFactory2.setLogFactory(LogFactory.getFactory()); }
From source file:org.apache.oozie.service.TestXLogService.java
@Override protected void setUp() throws Exception { super.setUp(); LogFactory.getFactory().release(); LogManager.resetConfiguration(); }