Search in sources :

Example 6 with Handler

use of java.util.logging.Handler in project randomizedtesting by randomizedtesting.

the class WithNestedTestClass method clearNested.

@AfterClass
public static final void clearNested() throws Exception {
    zombieToken = null;
    runningNested = false;
    ApplyAtPlace.runnable = null;
    ApplyAtPlace.place = null;
    System.setOut(sysout);
    System.setErr(syserr);
    for (Handler h : logger.getHandlers()) logger.removeHandler(h);
    for (Handler h : handlers) logger.addHandler(h);
    for (Thread t : zombies) {
        t.interrupt();
    }
    for (Thread t : zombies) {
        t.join();
    }
}
Also used : Handler(java.util.logging.Handler) AfterClass(org.junit.AfterClass)

Example 7 with Handler

use of java.util.logging.Handler in project spring-boot by spring-projects.

the class LogbackLoggingSystemTests method bridgeHandlerInstalled.

private boolean bridgeHandlerInstalled() {
    java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger("");
    Handler[] handlers = rootLogger.getHandlers();
    for (Handler handler : handlers) {
        if (handler instanceof SLF4JBridgeHandler) {
            return true;
        }
    }
    return false;
}
Also used : SLF4JBridgeHandler(org.slf4j.bridge.SLF4JBridgeHandler) SLF4JBridgeHandler(org.slf4j.bridge.SLF4JBridgeHandler) Handler(java.util.logging.Handler)

Example 8 with Handler

use of java.util.logging.Handler in project gfm_viewer by satyagraha.

the class SimpleLogging method setupLogging.

public static void setupLogging() {
    if (isDebugging()) {
        Logger rootLogger = Logger.getLogger("");
        for (Handler handler : rootLogger.getHandlers()) {
            handler.setLevel(Level.FINE);
        }
        // Set root logger level
        rootLogger.setLevel(Level.FINE);
    }
}
Also used : Handler(java.util.logging.Handler) Logger(java.util.logging.Logger)

Example 9 with Handler

use of java.util.logging.Handler in project syncany by syncany.

the class CommandLineClient method initLogHandlers.

private void initLogHandlers(OptionSet options, OptionSpec<String> optionLog, OptionSpec<Void> optionLogPrint, OptionSpec<Void> optionDebug) throws SecurityException, IOException {
    // --log=<file>
    String logFilePattern = null;
    if (options.has(optionLog)) {
        if (!"-".equals(options.valueOf(optionLog))) {
            logFilePattern = options.valueOf(optionLog);
        }
    } else if (config != null && config.getLogDir().exists()) {
        logFilePattern = config.getLogDir() + File.separator + LOG_FILE_PATTERN;
    } else {
        logFilePattern = UserConfig.getUserLogDir() + File.separator + LOG_FILE_PATTERN;
    }
    if (logFilePattern != null) {
        Handler fileLogHandler = new FileHandler(logFilePattern, LOG_FILE_LIMIT, LOG_FILE_COUNT, true);
        fileLogHandler.setFormatter(new LogFormatter());
        Logging.addGlobalHandler(fileLogHandler);
    }
    // --debug, add console handler
    if (options.has(optionDebug) || options.has(optionLogPrint) || (options.has(optionLog) && "-".equals(options.valueOf(optionLog)))) {
        Handler consoleLogHandler = new ConsoleHandler();
        consoleLogHandler.setFormatter(new LogFormatter());
        Logging.addGlobalHandler(consoleLogHandler);
    }
}
Also used : FileHandler(java.util.logging.FileHandler) Handler(java.util.logging.Handler) ConsoleHandler(java.util.logging.ConsoleHandler) LogFormatter(org.syncany.config.LogFormatter) ConsoleHandler(java.util.logging.ConsoleHandler) FileHandler(java.util.logging.FileHandler)

Example 10 with Handler

use of java.util.logging.Handler in project commons by twitter.

the class RootLogConfig method setConsoleHandler.

private static void setConsoleHandler(Logger logger, boolean removeOtherHandlers) {
    Handler consoleHandler = null;
    for (Handler h : logger.getHandlers()) {
        if (h instanceof ConsoleHandler) {
            consoleHandler = h;
        } else if (removeOtherHandlers) {
            logger.removeHandler(h);
        }
    }
    if (consoleHandler == null) {
        consoleHandler = new ConsoleHandler();
        logger.addHandler(new ConsoleHandler());
    }
    consoleHandler.setLevel(Level.ALL);
    consoleHandler.setFilter(null);
}
Also used : ConsoleHandler(java.util.logging.ConsoleHandler) Handler(java.util.logging.Handler) ConsoleHandler(java.util.logging.ConsoleHandler)

Aggregations

Handler (java.util.logging.Handler)108 Logger (java.util.logging.Logger)35 ConsoleHandler (java.util.logging.ConsoleHandler)22 LogRecord (java.util.logging.LogRecord)16 Test (org.junit.Test)15 FileHandler (java.util.logging.FileHandler)13 IOException (java.io.IOException)9 File (java.io.File)8 Level (java.util.logging.Level)7 SimpleFormatter (java.util.logging.SimpleFormatter)7 Formatter (java.util.logging.Formatter)6 LogManager (java.util.logging.LogManager)6 PrintStream (java.io.PrintStream)5 ArrayList (java.util.ArrayList)4 SLF4JBridgeHandler (org.slf4j.bridge.SLF4JBridgeHandler)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 StringTokenizer (java.util.StringTokenizer)3 StdOutConsoleHandler (alma.acs.logging.StdOutConsoleHandler)2 ConsoleLogFormatter (alma.acs.logging.formatters.ConsoleLogFormatter)2 MonitoredResource (com.google.cloud.MonitoredResource)2