Search in sources :

Example 16 with ConsoleHandler

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

the class JavaLogger method configure.

/**
     * Configures handlers when needed.
     *
     * @param initImpl Optional log implementation.
     */
private void configure(@Nullable Logger initImpl) {
    if (initImpl != null)
        impl = initImpl;
    if (inited)
        return;
    synchronized (mux) {
        if (inited)
            return;
        if (isConfigured()) {
            boolean consoleHndFound = findHandler(impl, ConsoleHandler.class) != null;
            // User configured console appender, thus log is not quiet.
            quiet0 = !consoleHndFound;
            inited = true;
            return;
        }
        defaultConfiguration();
        boolean quiet = Boolean.valueOf(System.getProperty(IGNITE_QUIET, "true"));
        boolean useConsoleAppender = Boolean.valueOf(System.getProperty(IGNITE_CONSOLE_APPENDER, "true"));
        if (useConsoleAppender) {
            ConsoleHandler consoleHnd = findHandler(impl, ConsoleHandler.class);
            if (consoleHnd != null)
                consoleHnd.setLevel(quiet ? SEVERE : INFO);
            else
                System.err.println("Console logging handler is not configured.");
        } else {
            Handler[] handlers = Logger.getLogger("").getHandlers();
            if (!F.isEmpty(handlers)) {
                for (Handler h : handlers) {
                    if (h instanceof ConsoleHandler)
                        impl.removeHandler(h);
                }
            }
        }
        quiet0 = quiet;
        inited = true;
    }
}
Also used : FileHandler(java.util.logging.FileHandler) ConsoleHandler(java.util.logging.ConsoleHandler) Handler(java.util.logging.Handler) ConsoleHandler(java.util.logging.ConsoleHandler)

Example 17 with ConsoleHandler

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

the class BootstrapLogManager method getDefaultHandlersInternal.

private List<Handler> getDefaultHandlersInternal() {
    String consoleLevel = System.getProperty("karaf.log.console", "OFF");
    ConsoleHandler handler = new ConsoleHandler();
    handler.setLevel(Level.parse(consoleLevel));
    return Arrays.asList(handler, getDefaultHandlerInternal());
}
Also used : ConsoleHandler(java.util.logging.ConsoleHandler)

Example 18 with ConsoleHandler

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

the class RoundRobinConnectionStrategyTest 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 19 with ConsoleHandler

use of java.util.logging.ConsoleHandler in project BKCommonLib by bergerhealer.

the class ModuleLogger method createDefaultLogger.

private static Logger createDefaultLogger() {
    if (!Common.IS_TEST_MODE)
        return Bukkit.getLogger();
    Logger log = Logger.getLogger("");
    log.setUseParentHandlers(false);
    CustomRecordFormatter formatter = new CustomRecordFormatter();
    ConsoleHandler consoleHandler = new ConsoleHandler();
    consoleHandler.setFormatter(formatter);
    for (Handler iHandler : log.getHandlers()) {
        log.removeHandler(iHandler);
    }
    log.addHandler(consoleHandler);
    return log;
}
Also used : ConsoleHandler(java.util.logging.ConsoleHandler) Handler(java.util.logging.Handler) Logger(java.util.logging.Logger) ConsoleHandler(java.util.logging.ConsoleHandler)

Example 20 with ConsoleHandler

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

the class KoBrowserTest method compatibilityTests.

@Factory
public static Object[] compatibilityTests() throws Exception {
    Browser.LOG.setLevel(Level.FINE);
    Browser.LOG.addHandler(new ConsoleHandler());
    final BrowserBuilder bb = BrowserBuilder.newBrowser(new Browser("KoBrowserTest")).loadClass(KoBrowserTest.class).loadPage("empty.html").invoke("initialized");
    Executors.newSingleThreadExecutor().submit(new Runnable() {

        @Override
        public void run() {
            bb.showAndWait();
        }
    });
    List<Object> res = new ArrayList<Object>();
    Class<? extends Annotation> test = loadClass().getClassLoader().loadClass(KOTest.class.getName()).asSubclass(Annotation.class);
    Class[] arr = (Class[]) loadClass().getDeclaredMethod("tests").invoke(null);
    final HttpServer s = Browser.findServer(browserPresenter);
    ServerConfiguration conf = s.getServerConfiguration();
    conf.addHttpHandler(new DynamicHTTP(s), "/dynamic");
    for (Class c : arr) {
        for (Method m : c.getMethods()) {
            if (m.getAnnotation(test) != null) {
                res.add(new KOScript(browserPresenter, m));
            }
        }
    }
    return res.toArray();
}
Also used : ServerConfiguration(org.glassfish.grizzly.http.server.ServerConfiguration) ArrayList(java.util.ArrayList) Method(java.lang.reflect.Method) ConsoleHandler(java.util.logging.ConsoleHandler) BrowserBuilder(net.java.html.boot.BrowserBuilder) HttpServer(org.glassfish.grizzly.http.server.HttpServer) Factory(org.testng.annotations.Factory)

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