Search in sources :

Example 26 with Handler

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

the class CLogMgt method setLevel.

//	setLoggerLevel
/**
	 * 	Set Level for all handlers
	 *	@param level log level
	 */
public static void setLevel(Level level) {
    if (level == null)
        return;
    if (s_handlers == null)
        initialize(true);
    //
    for (int i = 0; i < s_handlers.size(); i++) {
        Handler handler = (Handler) s_handlers.get(i);
        handler.setLevel(level);
    }
    //	JDBC if ALL
    setJDBCDebug(s_currentLevel.intValue() == Level.ALL.intValue());
    //
    if (level.intValue() != s_currentLevel.intValue()) {
        setLoggerLevel(level, null);
        log.config(level.toString());
    }
    s_currentLevel = level;
}
Also used : Handler(java.util.logging.Handler)

Example 27 with Handler

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

the class SilentSetup method main.

/**
	 * 	Start
	 * 	@param args Log Level e.g. ALL, FINE
	 */
public static void main(String[] args) {
    CLogMgt.initialize(true);
    Handler fileHandler = new CLogFile(System.getProperty("user.dir"), false, false);
    CLogMgt.addHandler(fileHandler);
    //	Log Level
    if (args.length > 0)
        CLogMgt.setLevel(args[0]);
    else
        CLogMgt.setLevel(Level.INFO);
    //	File Logger at least FINE
    if (fileHandler.getLevel().intValue() > Level.FINE.intValue())
        fileHandler.setLevel(Level.FINE);
    new SilentSetup();
}
Also used : CLogFile(org.compiere.util.CLogFile) Handler(java.util.logging.Handler)

Example 28 with Handler

use of java.util.logging.Handler in project geode by apache.

the class GfshInitFileJUnitTest method setUpBeforeClass.

/*
   * Turn off console logging from JUL and Log4j2 for the duration of this class's tests, to reduce
   * noise level of output in automated build.
   */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    saveLog4j2Config = System.getProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
    julLogger = java.util.logging.Logger.getLogger("");
    saveHandlers = julLogger.getHandlers();
    for (Handler handler : saveHandlers) {
        julLogger.removeHandler(handler);
    }
    File log4j2XML = temporaryFolder_Config.newFile("log4j2.xml");
    FileUtils.writeStringToFile(log4j2XML, "<Configuration/>", APPEND);
    System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY, log4j2XML.toURI().toString());
}
Also used : Handler(java.util.logging.Handler) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 29 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 30 with Handler

use of java.util.logging.Handler in project google-cloud-java by GoogleCloudPlatform.

the class LoggingHandlerTest method testClose.

@Test
public void testClose() throws Exception {
    expect(options.getProjectId()).andReturn(PROJECT).anyTimes();
    expect(options.getService()).andReturn(logging);
    logging.setFlushSeverity(Severity.ERROR);
    expectLastCall().once();
    logging.setWriteSynchronicity(Synchronicity.ASYNC);
    expectLastCall().once();
    logging.write(ImmutableList.of(FINEST_ENTRY), DEFAULT_OPTIONS);
    expectLastCall().once();
    logging.close();
    expectLastCall().once();
    replay(options, logging);
    Handler handler = new LoggingHandler(LOG_NAME, options);
    handler.setLevel(Level.ALL);
    handler.setFormatter(new TestFormatter());
    handler.publish(newLogRecord(Level.FINEST, MESSAGE));
    handler.close();
    handler.close();
}
Also used : Handler(java.util.logging.Handler) Test(org.junit.Test)

Aggregations

Handler (java.util.logging.Handler)135 Logger (java.util.logging.Logger)52 ConsoleHandler (java.util.logging.ConsoleHandler)30 LogRecord (java.util.logging.LogRecord)24 Test (org.junit.Test)22 FileHandler (java.util.logging.FileHandler)17 File (java.io.File)14 IOException (java.io.IOException)13 Level (java.util.logging.Level)11 SimpleFormatter (java.util.logging.SimpleFormatter)8 Formatter (java.util.logging.Formatter)7 LogManager (java.util.logging.LogManager)6 PrintStream (java.io.PrintStream)5 ArrayList (java.util.ArrayList)5 SLF4JBridgeHandler (org.slf4j.bridge.SLF4JBridgeHandler)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 FileInputStream (java.io.FileInputStream)3 InputStream (java.io.InputStream)3 StringTokenizer (java.util.StringTokenizer)3 StdOutConsoleHandler (alma.acs.logging.StdOutConsoleHandler)2