Example usage for org.apache.commons.logging LogFactory getFactory

List of usage examples for org.apache.commons.logging LogFactory getFactory

Introduction

In this page you can find the example usage for org.apache.commons.logging LogFactory getFactory.

Prototype

@Deprecated
public static LogFactory getFactory() 

Source Link

Document

This method only exists for compatibility with unusual Commons Logging API usage like e.g.

Usage

From source file:net.sourceforge.floggy.maven.PersistenceMojo.java

/**
 * DOCUMENT ME!//  ww  w .  j a v a2s .c  o m
*
* @throws MojoExecutionException DOCUMENT ME!
*/
public void execute() throws MojoExecutionException {
    MavenLogWrapper.setLog(getLog());

    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
            "net.sourceforge.floggy.maven.MavenLogWrapper");

    Weaver weaver = new Weaver();

    try {
        List list = project.getCompileClasspathElements();
        File temp = new File(project.getBuild().getDirectory(), String.valueOf(System.currentTimeMillis()));
        FileUtils.forceMkdir(temp);
        weaver.setOutputFile(temp);
        weaver.setInputFile(input);
        weaver.setClasspath((String[]) list.toArray(new String[list.size()]));

        if (configurationFile == null) {
            Configuration configuration = new Configuration();
            configuration.setAddDefaultConstructor(addDefaultConstructor);
            configuration.setGenerateSource(generateSource);
            weaver.setConfiguration(configuration);
        } else {
            weaver.setConfigurationFile(configurationFile);
        }

        weaver.execute();
        FileUtils.copyDirectory(temp, output);
        FileUtils.forceDelete(temp);
    } catch (Exception e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}

From source file:fr.gouv.vitam.utils.logging.CommonsLoggerFactory.java

@Override
protected VitamLogLevel getLevelSpecific() {
    final Log logger = LogFactory.getFactory().getInstance("foo");
    if (logger.isTraceEnabled()) {
        return VitamLogLevel.TRACE;
    } else if (logger.isDebugEnabled()) {
        return VitamLogLevel.DEBUG;
    } else if (logger.isInfoEnabled()) {
        return VitamLogLevel.INFO;
    } else if (logger.isWarnEnabled()) {
        return VitamLogLevel.WARN;
    } else if (logger.isErrorEnabled()) {
        return VitamLogLevel.ERROR;
    }//from   w ww.j a  v a 2  s  .c om
    return null;
}

From source file:fr.lip6.move.pnml.framework.utils.logging.LogMaster.java

/**
 * Gives a logger.//from  www.jav a2s  .  c o m
 *
 * @param name
 *            The logger name identification
 * @return a Logger
 * @see org.apache.commons.logging.Log
 * @deprecated @see {{@link #getLogger(String)}
 */
public static synchronized Log giveLogger(String name) { // NOPMD by
    // ggiffo on
    // 7/21/08 5:00
    // PM
    if (instance == null) {
        instance = new LogMaster();
    }
    return LogFactory.getFactory().getInstance(name);
}

From source file:greenfoot.export.mygame.MyGameClient.java

public MyGameClient(PublishListener listener) {
    this.listener = listener;

    // Disable logging, prevents guff going to System.err
    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log",
            "org.apache.commons.logging.impl.NoOpLog");
}

From source file:com.google.jstestdriver.idea.ui.MainUI.java

private static void configureLogging() {
    // Configure commons logging to log to the Swing log panel logger
    LogFactory.getFactory().setAttribute(JCL_LOG_CONFIG_ATTR, LogPanelLog.class.getName());
    // Configure Jetty to log to SLF4J. Since slf4j-jcl.jar is in the classpath, SLF4J will be
    // configured to delegate logging to commons logging.
    System.setProperty(JETTY_LOG_CLASS_PROP, Slf4jLog.class.getName());
    System.setProperty(JCL_SIMPLELOG_SHOW_SHORT_LOGNAME, "false");
    System.setProperty(JCL_SIMPLELOG_SHOWLOGNAME, "false");
}

From source file:com.puppycrawl.tools.checkstyle.checks.usage.transmogrify.Resolver.java

/**
 * constructor with <code>SymbolTable</code> to be resolved
 *//*from  www.j a va 2  s .c o m*/
public Resolver(SymbolTable symbolTable) {
    super(symbolTable);

    try {
        mLogFactory = LogFactory.getFactory();
    } catch (LogConfigurationException e) {
        System.out.println("log configuration exception" + e);
    }
    mInitialized = true;

}

From source file:net.sf.ginp.TestSetupInvalid.java

/**
 * Sets up test by creating registry//w  w  w. j ava  2s .  c o  m
 *
 * The logging environment is special... we want to suppress the
 * expected high number of stack traces from XML errors because
 * they make the test appear to be failing even though it is working
 * properly. If we suppress all logging lower than "fatal", then
 * RegistryBuilder croaks. Therefore, we have to set a high
 * logging threshold for just the two specific loggers.
 * @see junit.framework.TestCase#setUp()
 */
public void setUp() {
    // want loggers that won't show error messages
    systemProperties.put(MY_LOG_PROPERTY, INHIBIT_ERRORS);
    systemProperties.put(XML_LOG_PROPERTY, INHIBIT_ERRORS);

    // grab the factory and try to get rid of any residual loggers
    LogFactory logFactory = LogFactory.getFactory();
    logFactory.release();
    // with luck, the System props will be merged into the
    // simple-log.properties values and set the desired level
    net.sf.ginp.config.Configuration.setConfigfilelocation(CONFIG_FILE_LOCATION);
    registry = RegistryBuilder.constructDefaultRegistry();
    service = (SetupManager) registry.getService(SetupManager.class);
}

From source file:facturas.PDF.CommandLineOptions.java

/**
 * Construct a command line option object.
 *//*from  w ww.  j  a  v a2 s. com*/
public CommandLineOptions(PDFGeneador geneador) {
    _generador = geneador;
    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:at.spardat.xma.boot.BootRuntime.java

/**
 * The BootRuntime constructor is private, because it is a singleton got only via initialize.
 * the constructor initializes the process properties and the basic directories.
 * the initialization of modules is seperated into 'initializeModules'.
 *
 * @param baseDir xma base dir.// ww  w  .  ja  v a  2s  .com
 * @param logger  an existing logger [optional ].
 */
private BootRuntime(File baseDir, Logger l) throws IOException {

    setInstallDirectory(baseDir);

    props = readBootCfgProperties(baseDir, l);

    /*
     * check data directory path information
     */
    String strDataDirectory = props.getProperty(Statics.CFG_PROP_DATAPATH);
    //if the prop CFG_PROP_DATAPATH is marked with CFG_PROP_DATAPATH_USER_HOME_VALUE then "user.home" is used
    if (strDataDirectory != null && strDataDirectory.startsWith(Statics.CFG_PROP_DATAPATH_USER_HOME_VALUE)) {
        strDataDirectory = System.getProperty("user.home")
                + strDataDirectory.substring(Statics.CFG_PROP_DATAPATH_USER_HOME_VALUE.length());
        props.put(Statics.CFG_PROP_DATAPATH, strDataDirectory);
        l.log(LogLevel.FINE,
                "Datapath Property set to " + Statics.CFG_PROP_DATAPATH_USER_HOME_VALUE + ", using: {0}",
                strDataDirectory);
    }
    //if the prop CFG_PROP_DATAPATH has no value then "user.dir" is used
    if (strDataDirectory == null || strDataDirectory.length() == 0) {
        strDataDirectory = System.getProperty("user.dir");
        props.put(Statics.CFG_PROP_DATAPATH, strDataDirectory);
        l.log(LogLevel.FINE, "Datapath Property not found defaults to user.dir: {0}", strDataDirectory);
    }

    dataDirectory = new File(strDataDirectory);
    if (!dataDirectory.exists()) {
        dataDirectory.mkdirs();
    }
    if (!dataDirectory.isDirectory()) {
        throw new RuntimeException("datapath '" + dataDirectory.getAbsolutePath() + "' is not a directory");
    }

    props.setProperty(Statics.CFG_PROP_LOGDIRECTORY, strDataDirectory);

    LogManager.getLogManager().setConfiguration(props);
    XMA_URI.setProperties(props);

    if (l != null)
        this.bootLogger = l;
    else
        this.bootLogger = Logger.getLogger("bootrt.bootRuntime"); //$NON-NLS-1$

    // tell apache.commons.logging to use the logger of XMABootRuntime
    LogFactory.getFactory().setAttribute("org.apache.commons.logging.Log", XmaBrtLogger.class.getName());

    String strDebug = (String) props.get(Statics.CFG_PROP_LOGLEVEL); //$NON-NLS-1$
    LogLevel level = LogLevel.getLogLevelNamed(strDebug);

    // extended output to files and other tracing information only on high log levels
    if (LogLevel.ALL.equals(level) || LogLevel.FINE.equals(level)) {
        setDebug(Boolean.TRUE);
        debugJavaParameter();
    } else {
        setDebug(Boolean.FALSE);
    }

    // read caching properties from registry
    String useRegistry = props.getProperty(Statics.CFG_PROP_USEREGISTRY, "true");
    if (Boolean.valueOf(useRegistry).booleanValue()) {
        getProxySettings(props, bootLogger);
    }

}

From source file:com.timeinc.seleniumite.junit.SimpleSeleniumBuilderTest.java

public void testSeleniumIdeFile() throws Exception {
    String threaded = (runSingleThreaded) ? "Single-Thread" : "Multi-Threaded";
    LOG.info("{} processing file : {}", threaded, testingEnvironment);

    List<String> failures = new LinkedList<>();
    RetryingTestRun lastRun = null;//from ww  w . ja  va2  s .  c  om
    Log log = LogFactory.getFactory().getInstance(SimpleSeleniumBuilderTest.class);
    HashMap<String, String> driverConfig = testingEnvironment
            .createDriverConfig(DefaultRawGlobalTestConfiguration.getDefault());
    Predicate<Exception> retryPredicate = createRetryPredicate();

    RetryingTestRunFactory testRunFactory = new RetryingTestRunFactory();

    for (Script script : testingEnvironment.createScripts()) {
        LoggingRemoteWebDriverFactory wdf = new LoggingRemoteWebDriverFactory(
                testingEnvironment.webDriverFactory(), script.name);

        LOG.info("Executing script {}", script.name);
        for (Map<String, String> data : script.dataRows) {
            Step currentStep = null;
            try {
                lastRun = testRunFactory.createTestRun(script, log, wdf, driverConfig, data, lastRun);

                Boolean lastStepResult = null;

                if (!lastRun.hasNext()) {
                    LOG.warn("Has next is false and havent started yet");
                }

                // Actually run the script
                while (lastRun.hasNext()) {
                    lastStepResult = lastRun.nextWithRetry(3, 3, retryPredicate); // 3 tries with 3 second waits
                    currentStep = lastRun.currentStep();
                    LOG.debug("{} for step : {}", lastStepResult, currentStep.toJSON());
                }
                String sessionId = "SID:" + SessionRegistry.INSTANCE.lookup(script.name, driverConfig);
                String message = createMessage(lastStepResult, testingEnvironment, sessionId, currentStep);
                LOG.info(message);

                if (!Boolean.TRUE.equals(lastStepResult)) {
                    failures.add(message);
                }
            } catch (Exception e) {
                Throwable throwableToLog = unwrapWebDriverException(e);
                String sessionId = "SID:" + SessionRegistry.INSTANCE.lookup(script.name, driverConfig);
                String message = createMessage(false, testingEnvironment, sessionId, currentStep,
                        throwableToLog);
                LOG.info(message);
                failures.add(message);
            }

            // Run "finish" so that it'll shut down the driver if necessary
            try {
                if (lastRun != null) {
                    lastRun.finish();
                }
            } catch (Exception e) {
                LOG.debug("Error while trying to shut down", e);
            }
        }
    }

    if (failures.size() > 0) {
        LOG.info("Failing test with : {}", failures);
        Assert.fail("Test Failure : " + failures.toString());
    }
}