Search in sources :

Example 1 with Logger

use of java.lang.System.Logger in project logging-log4j2 by apache.

the class Log4jSystemLoggerTest method testLogWithCallingClass.

@Test
public void testLogWithCallingClass() throws Exception {
    final Logger log = System.getLogger("Test.CallerClass");
    log.log(Logger.Level.INFO, "Calling from LoggerTest");
    final List<String> messages = stringAppender.getMessages();
    assertThat(messages, hasSize(1));
    final String message = messages.get(0);
    assertEquals(Log4jSystemLoggerTest.class.getName(), message);
}
Also used : Logger(java.lang.System.Logger) Test(org.junit.Test)

Example 2 with Logger

use of java.lang.System.Logger in project Bytecoder by mirkosertic.

the class AbstractLoggerWrapper method logp.

@Override
public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, Throwable thrown, Supplier<String> msgSupplier) {
    final PlatformLogger.Bridge platformProxy = platformProxy();
    if (platformProxy == null) {
        // best effort
        if (sourceClass == null && sourceMethod == null) {
            wrapped().log(level.systemLevel(), msgSupplier, thrown);
        } else {
            Level systemLevel = level.systemLevel();
            Logger wrapped = wrapped();
            if (wrapped.isLoggable(systemLevel)) {
                final String sClass = sourceClass == null ? "" : sourceClass;
                final String sMethod = sourceMethod == null ? "" : sourceMethod;
                wrapped.log(systemLevel, () -> String.format("[%s %s] %s", sClass, sMethod, msgSupplier.get()), thrown);
            }
        }
    } else {
        platformProxy.logp(level, sourceClass, sourceMethod, thrown, msgSupplier);
    }
}
Also used : Level(java.lang.System.Logger.Level) PlatformLogger(sun.util.logging.PlatformLogger) PlatformLogger(sun.util.logging.PlatformLogger) Logger(java.lang.System.Logger)

Example 3 with Logger

use of java.lang.System.Logger in project Bytecoder by mirkosertic.

the class AbstractLoggerWrapper method logrb.

@Override
public void logrb(PlatformLogger.Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Object... params) {
    final PlatformLogger.Bridge platformProxy = platformProxy();
    if (platformProxy == null) {
        // best effort
        if (bundle != null || sourceClass == null && sourceMethod == null) {
            wrapped().log(level.systemLevel(), bundle, msg, params);
        } else {
            Level systemLevel = level.systemLevel();
            Logger wrapped = wrapped();
            if (wrapped.isLoggable(systemLevel)) {
                sourceClass = sourceClass == null ? "" : sourceClass;
                sourceMethod = sourceMethod == null ? "" : sourceMethod;
                msg = msg == null ? "" : msg;
                wrapped.log(systemLevel, bundle, String.format("[%s %s] %s", sourceClass, sourceMethod, msg), params);
            }
        }
    } else {
        platformProxy.logrb(level, sourceClass, sourceMethod, bundle, msg, params);
    }
}
Also used : Level(java.lang.System.Logger.Level) PlatformLogger(sun.util.logging.PlatformLogger) PlatformLogger(sun.util.logging.PlatformLogger) Logger(java.lang.System.Logger)

Example 4 with Logger

use of java.lang.System.Logger in project Bytecoder by mirkosertic.

the class AbstractLoggerWrapper method logp.

@Override
public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, String msg) {
    final PlatformLogger.Bridge platformProxy = platformProxy();
    if (platformProxy == null) {
        if (sourceClass == null && sourceMethod == null) {
            // best effort
            wrapped().log(level.systemLevel(), msg);
        } else {
            Level systemLevel = level.systemLevel();
            Logger wrapped = wrapped();
            if (wrapped.isLoggable(systemLevel)) {
                sourceClass = sourceClass == null ? "" : sourceClass;
                sourceMethod = sourceMethod == null ? "" : sourceMethod;
                msg = msg == null ? "" : msg;
                wrapped.log(systemLevel, String.format("[%s %s] %s", sourceClass, sourceMethod, msg));
            }
        }
    } else {
        platformProxy.logp(level, sourceClass, sourceMethod, msg);
    }
}
Also used : Level(java.lang.System.Logger.Level) PlatformLogger(sun.util.logging.PlatformLogger) PlatformLogger(sun.util.logging.PlatformLogger) Logger(java.lang.System.Logger)

Example 5 with Logger

use of java.lang.System.Logger in project Bytecoder by mirkosertic.

the class BootstrapLogger method log.

@Override
public void log(Level level, Supplier<String> msgSupplier, Throwable thrown) {
    if (checkBootstrapping()) {
        push(LogEvent.valueOf(this, level, msgSupplier, thrown));
    } else {
        final Logger spi = holder.wrapped();
        spi.log(level, msgSupplier, thrown);
    }
}
Also used : PlatformLogger(sun.util.logging.PlatformLogger) Logger(java.lang.System.Logger)

Aggregations

Logger (java.lang.System.Logger)58 IOException (java.io.IOException)39 ArrayList (java.util.ArrayList)38 FileOutputStream (java.io.FileOutputStream)36 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)34 SAXException (org.xml.sax.SAXException)34 URISyntaxException (java.net.URISyntaxException)28 File (java.io.File)23 Element (com.maxprograms.xml.Element)22 Document (com.maxprograms.xml.Document)17 FileInputStream (java.io.FileInputStream)16 PlatformLogger (sun.util.logging.PlatformLogger)16 SAXBuilder (com.maxprograms.xml.SAXBuilder)14 XMLOutputter (com.maxprograms.xml.XMLOutputter)14 Catalog (com.maxprograms.xml.Catalog)13 BufferedReader (java.io.BufferedReader)13 InputStreamReader (java.io.InputStreamReader)11 Segmenter (com.maxprograms.segmenter.Segmenter)7 Level (java.lang.System.Logger.Level)7 HashMap (java.util.HashMap)5