Example usage for java.util.logging LogManager getLogManager

List of usage examples for java.util.logging LogManager getLogManager

Introduction

In this page you can find the example usage for java.util.logging LogManager getLogManager.

Prototype

public static LogManager getLogManager() 

Source Link

Document

Returns the global LogManager object.

Usage

From source file:com.ellychou.todo.rest.service.SpringContextJerseyTest.java

/**
* Retrieves a list of root loggers./*from w  w w  .j a  v  a  2s. c  om*/
*
* @return list of root loggers.
*/
private Set<Logger> getRootLoggers() {
    final LogManager logManager = LogManager.getLogManager();
    final Enumeration<String> loggerNames = logManager.getLoggerNames();

    final Set<Logger> rootLoggers = Sets.newHashSet();

    while (loggerNames.hasMoreElements()) {
        Logger logger = logManager.getLogger(loggerNames.nextElement());
        if (logger != null) {
            while (logger.getParent() != null) {
                logger = logger.getParent();
            }
            rootLoggers.add(logger);
        }
    }

    return rootLoggers;
}

From source file:com.searchtechnologies.aspire.components.heritrixconnector.HeritrixScanner.java

@Override
public void doAdditionalInitialization(Element config) throws AspireException {
    if (config == null)
        return;//from   w w  w .jav  a2 s .c  o  m

    bh = BranchHandlerFactory.newInstance(config, this);

    heritrixJobsDir = getStringFromConfig(config, "jobsFolder", appDataDir("heritrixJobs"));
    heritrixJobsDir = getFilePathFromAspireHome(heritrixJobsDir);

    sourceDisplayName = getStringFromConfig(config, "displayName", sourceDisplayName);

    configFileLocation = getStringFromConfig(config, "configFileLocation", configFileLocation);

    if (configFileLocation != null)
        defaultConfigFile = false;

    crawlPatterns = AspireObject.createFromXML(new StringReader(AXML.toString(config))).get("crawlPatterns");

    mapDBDir = getStringFromConfig(config, "jdbmDir", appDataDir("incremental"));

    checkNotCrawlableContent = getBooleanFromConfig(config, "checkNotCrawlableContent", false);

    daysFailedThreshold = getIntegerFromConfig(config, "daysToDelete", 2, 1, Integer.MAX_VALUE);

    maxFailures = getIntegerFromConfig(config, "maxFailuresToDelete", 5, 1, Integer.MAX_VALUE);

    uncrawledAccessDelay = getLongFromConfig(config, "uncrawledAccessDelay", 2000L, 1L, 100000L);

    maxHops = getIntegerFromConfig(config, "maxHops", maxHops, 1, 20);

    maxDelayMs = getLongFromConfig(config, "millisecondsPerRequest", maxDelayMs, 1L, 100000L);

    scope = getStringFromConfig(config, "scope", scope);

    updaterComponentName = getStringFromConfig(config, "updaterComponent", null);

    if (StringUtilities.isNotEmpty(updaterComponentName)) {
        info("Using updater job component: %s", updaterComponentName);
    }
    waitForSubJobsTimeout = getLongFromConfig(config, "waitForSubJobsTimeout", waitForSubJobsTimeout, 0L, null);

    checkpointIntervalMinutes = getIntegerFromConfig(config, "checkpointIntervalMinutes", 15, 1,
            Integer.MAX_VALUE);

    deletedUrlsLog = new RotatingFileWriter(
            this.getFilePathFromAspireHome("log") + "/" + this.getAppName() + "/deleted.jobs");
    failedUrlsLog = new RotatingFileWriter(
            this.getFilePathFromAspireHome("log") + "/" + this.getAppName() + "/failed.jobs");

    HttpAuthenticationCredential.securityManager = new AspireSecurityManager();

    FileInputStream finp;
    File properties = new File(heritrixJobsDir + "/logging.properties");
    System.setProperty("java.util.logging.config.file", properties.getAbsolutePath());

    //Loads the heritrix engine
    engine = new Engine(new File(heritrixJobsDir));

    try {
        if (properties.exists()) {
            finp = new FileInputStream(properties);
            LogManager.getLogManager().readConfiguration(finp);
        }
    } catch (FileNotFoundException e) {
        error(e, "FileNotFoundException exception whilst reading configuration");
    } catch (SecurityException e) {
        error(e, "SecurityException exception whilst reading configuration");
    } catch (IOException e) {
        error(e, "IO exception whilst reading configuration");
    }
}

From source file:org.apache.kylin.query.KylinTestBase.java

protected int runSQL(File sqlFile, boolean debug, boolean explain) throws Exception {
    if (debug) {/*from w  w  w. j av  a 2  s .  c om*/
        System.setProperty("calcite.debug", "true");
        InputStream inputStream = new FileInputStream("src/test/resources/logging.properties");
        LogManager.getLogManager().readConfiguration(inputStream);
    }

    String queryName = StringUtils.split(sqlFile.getName(), '.')[0];
    logger.info("Testing Query " + queryName);
    String sql = getTextFromFile(sqlFile);
    if (explain) {
        sql = "explain plan for " + sql;
    }
    int count = executeQuery(sql, true);

    if (debug) {
        System.clearProperty("calcite.debug");
    }
    return count;
}

From source file:org.springframework.boot.context.logging.LoggingApplicationListenerTests.java

private boolean bridgeHandlerInstalled() {
    Logger rootLogger = LogManager.getLogManager().getLogger("");
    Handler[] handlers = rootLogger.getHandlers();
    for (Handler handler : handlers) {
        if (handler instanceof SLF4JBridgeHandler) {
            return true;
        }/*from  w w w.  j  a v  a  2 s.c o  m*/
    }
    return false;
}

From source file:fr.msch.wissl.server.Library.java

private static void stfuLog4j() {
    Properties props = new Properties();
    // props.setProperty("org.jaudiotagger.level",
    // Level.WARNING.toString());
    props.setProperty(".level", Level.OFF.toString());
    // props.setProperty("handlers",
    // "java.util.logging.ConsoleHandler,java.util.logging.FileHandler");
    try {/*from   ww w.  j a v  a2  s .  c  o  m*/
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        props.store(baos, null);
        byte[] data = baos.toByteArray();
        baos.close();
        ByteArrayInputStream bais = new ByteArrayInputStream(data);
        LogManager.getLogManager().readConfiguration(bais);
    }

    catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:brainflow.app.toplevel.BrainFlow.java

private void initLogMonitor() {
    DockableFrame dframe = DockWindowManager.getInstance().createDockableFrame("Log Monitor",
            "icons/console_view.gif", DockContext.STATE_AUTOHIDE, DockContext.DOCK_SIDE_SOUTH, 1);

    LogMonitor monitor = new LogMonitor();
    monitor.setLevel(Level.FINEST);
    LogManager.getLogManager().getLogger("").addHandler(monitor);
    dframe.getContentPane().add(new JScrollPane(monitor.getComponent()));

    dframe.setPreferredSize(new Dimension(800, 200));
    brainFrame.getDockingManager().addFrame(dframe);

}

From source file:com.cyberway.issue.crawler.Heritrix.java

/**
 * If the user hasn't altered the default logging parameters, tighten them
 * up somewhat: some of our libraries are way too verbose at the INFO or
 * WARNING levels./*from  w ww.  j ava 2 s.c o  m*/
 * 
 * This might be a problem running inside in someone else's
 * container.  Container's seem to prefer commons logging so we
 * ain't messing them doing the below.
 *
 * @throws IOException
 * @throws SecurityException
 */
protected static void patchLogging() throws SecurityException, IOException {
    if (System.getProperty("java.util.logging.config.class") != null) {
        return;
    }

    if (System.getProperty("java.util.logging.config.file") != null) {
        return;
    }

    // No user-set logging properties established; use defaults
    // from distribution-packaged 'heritrix.properties'.
    LogManager.getLogManager().readConfiguration(getPropertiesInputStream());
}