Search in sources :

Example 46 with ConsoleHandler

use of java.util.logging.ConsoleHandler in project tomee by apache.

the class ReconnectDelayListSelfTest method set.

private static void set(final Logger logger, final Level level) {
    final ConsoleHandler consoleHandler = new ConsoleHandler();
    consoleHandler.setLevel(level);
    logger.addHandler(consoleHandler);
    logger.setLevel(level);
    logger.setUseParentHandlers(false);
}
Also used : ConsoleHandler(java.util.logging.ConsoleHandler)

Example 47 with ConsoleHandler

use of java.util.logging.ConsoleHandler in project gatk by broadinstitute.

the class LoggingUtils method setJavaUtilLoggingLevel.

/**
     * Set the java.util.logging level since some of our dependencies write messages using it.
     *
     * Taken with modifications from a post by michel.iamit
     * http://stackoverflow.com/users/369060/michel-iamit
     * from http://stackoverflow.com/questions/470430/java-util-logging-logger-doesnt-respect-java-util-logging-level
     */
private static void setJavaUtilLoggingLevel(final Log.LogLevel verbosity) {
    Logger topLogger = java.util.logging.Logger.getLogger("");
    Handler consoleHandler = null;
    for (Handler handler : topLogger.getHandlers()) {
        if (handler instanceof ConsoleHandler) {
            consoleHandler = handler;
            break;
        }
    }
    if (consoleHandler == null) {
        consoleHandler = new ConsoleHandler();
        topLogger.addHandler(consoleHandler);
    }
    consoleHandler.setLevel(levelToJavaUtilLevel(verbosity));
}
Also used : ConsoleHandler(java.util.logging.ConsoleHandler) Handler(java.util.logging.Handler) Logger(java.util.logging.Logger) ConsoleHandler(java.util.logging.ConsoleHandler)

Example 48 with ConsoleHandler

use of java.util.logging.ConsoleHandler in project ceylon-compiler by ceylon.

the class Launcher method initLogger.

private static void initLogger(Logger logger, boolean verbose) {
    boolean handlersExists = false;
    for (Handler handler : logger.getHandlers()) {
        handlersExists = true;
        // formatter has to be in the boot class path. This way it doesn't.
        if (handler instanceof ConsoleHandler) {
            handler.setFormatter(CeylonLogFormatter.INSTANCE);
            if (verbose) {
                handler.setLevel(Level.ALL);
            }
        }
    }
    if (verbose) {
        //TODO do not configure root logger, make it flags aware
        logger.setLevel(Level.ALL);
        if (handlersExists == false) {
            ConsoleHandler handler = new ConsoleHandler();
            handler.setFormatter(CeylonLogFormatter.INSTANCE);
            handler.setLevel(Level.ALL);
            logger.addHandler(handler);
        }
    }
}
Also used : ConsoleHandler(java.util.logging.ConsoleHandler) Handler(java.util.logging.Handler) ConsoleHandler(java.util.logging.ConsoleHandler)

Example 49 with ConsoleHandler

use of java.util.logging.ConsoleHandler in project dukescript-presenters by dukescript.

the class Test method main.

public static void main(final String... args) throws Exception {
    Logger l = Logger.getLogger("com.dukescript");
    l.setLevel(Level.FINE);
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.FINE);
    l.addHandler(ch);
    l.setUseParentHandlers(false);
    Thread t = new Thread("Testing harness") {

        @Override
        public void run() {
            try {
                processTests();
            } catch (Exception ex) {
                LOG.log(Level.SEVERE, null, ex);
            }
        }
    };
    t.start();
    BrowserBuilder.newBrowser().loadPage("pages/test.html").loadClass(Test.class).invoke("onLoad", args).showAndWait();
}
Also used : Logger(java.util.logging.Logger) ConsoleHandler(java.util.logging.ConsoleHandler) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ConsoleHandler (java.util.logging.ConsoleHandler)49 Handler (java.util.logging.Handler)19 Logger (java.util.logging.Logger)15 LogRecord (java.util.logging.LogRecord)13 Properties (java.util.Properties)12 IOException (java.io.IOException)5 PrintStream (java.io.PrintStream)5 FileHandler (java.util.logging.FileHandler)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 SimpleFormatter (java.util.logging.SimpleFormatter)4 File (java.io.File)3 ArrayList (java.util.ArrayList)2 Formatter (java.util.logging.Formatter)2 CommandCenterLogic (alma.acs.commandcenter.app.CommandCenterLogic)1 StartupOptions (alma.acs.commandcenter.app.CommandCenterLogic.StartupOptions)1 JmeFormatter (com.jme3.util.JmeFormatter)1 RcvrExceptionHandler (edu.cmu.cs.hcii.cogtool.ui.RcvrExceptionHandler)1 Rectangle (java.awt.Rectangle)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1