Java 类org.slf4j.ext.XLoggerFactory 实例源码

项目:clustercode    文件:Startup.java   
public static void main(String[] args) throws Exception {

        List<String> logFiles = Arrays.asList("log4j2.xml", System.getenv("CC_LOG_CONFIG_FILE"));

        logFiles.forEach(name -> {
            if (name == null) return;
            Path logFile = Paths.get(name);
            if (Files.exists(logFile)) {
                System.setProperty("log4j.configurationFile", logFile.toAbsolutePath().toString());
            }
        });
        log = XLoggerFactory.getXLogger(Startup.class);

        Thread.setDefaultUncaughtExceptionHandler((thread, throwable) -> {
            // Normally the exceptions will be caught, but to debug any unexpected ones we log them (again).
            log.error("Application-wide uncaught exception:", throwable);
            System.exit(1);
        });

        log.info("Working dir: {}", new File("").getAbsolutePath());

        Properties config = getProperties(args.length >= 1 ? args[0] : null);

        GuiceContainer container = new GuiceContainer(config);

        container.getInstance(RestApiServices.class).start();
        container.getInstance(StateMachineService.class).initialize();
    }
项目:bartleby    文件:XLoggerTest.java   
public void testEntering() {
    XLogger logger = XLoggerFactory.getXLogger("UnitTest");
    logger.entry();
    logger.entry(1);
    logger.entry("test");
    logger.entry("a", "b", "c", "d");
    logger.entry("a", "b", "c", "d", "e");
    logger.entry("a", "b", "c", "d", "e", "f");

    assertEquals(6, listAppender.list.size());
    verify((LoggingEvent) listAppender.list.get(0), "entry");
    verify((LoggingEvent) listAppender.list.get(1), "entry with (1)");
    verify((LoggingEvent) listAppender.list.get(2), "entry with (test)");
}
项目:bartleby    文件:XLoggerTest.java   
public void testExiting() {
    XLogger logger = XLoggerFactory.getXLogger("UnitTest");
    logger.exit();
    assertEquals(Integer.valueOf(0), logger.exit(0));
    assertEquals(Boolean.FALSE, logger.exit(false));

    assertEquals(3, listAppender.list.size());
    verify((LoggingEvent) listAppender.list.get(0), "exit");
    verify((LoggingEvent) listAppender.list.get(1), "exit with (0)");
    verify((LoggingEvent) listAppender.list.get(2), "exit with (false)");
}
项目:bartleby    文件:XLoggerTest.java   
public void testThrowing() {
    XLogger logger = XLoggerFactory.getXLogger("UnitTest");
    Throwable t = new UnsupportedOperationException("Test");
    assertEquals(t, logger.throwing(t));
    assertEquals(t, logger.throwing(XLogger.Level.DEBUG, t));
    assertEquals(2, listAppender.list.size());
    verifyWithException((LoggingEvent) listAppender.list.get(0), "throwing", t);
    LoggingEvent event = (LoggingEvent) listAppender.list.get(1);
    verifyWithLevelAndException(event, XLogger.Level.DEBUG, "throwing", t);
}
项目:bartleby    文件:XLoggerTest.java   
public void testCaught() {
    XLogger logger = XLoggerFactory.getXLogger("UnitTest");
    long x = 5;
    Throwable t = null;
    try {
        @SuppressWarnings("unused")
        long y = x / 0;
    } catch (Exception ex) {
        t = ex;
        logger.catching(ex);
        logger.catching(XLogger.Level.DEBUG, ex);
    }
    verifyWithException((LoggingEvent) listAppender.list.get(0), "catching", t);
    verifyWithLevelAndException((LoggingEvent) listAppender.list.get(1), XLogger.Level.DEBUG, "catching", t);
}
项目:clustercode    文件:LoggedAction.java   
public LoggedAction withName(Class name) {
    this.log = XLoggerFactory.getXLogger(name);
    return this;
}