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();
}
java类org.slf4j.ext.XLoggerFactory的实例源码
Startup.java 文件源码
项目:clustercode
阅读 36
收藏 0
点赞 0
评论 0
XLoggerTest.java 文件源码
项目:bartleby
阅读 22
收藏 0
点赞 0
评论 0
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)");
}
XLoggerTest.java 文件源码
项目:bartleby
阅读 26
收藏 0
点赞 0
评论 0
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)");
}
XLoggerTest.java 文件源码
项目:bartleby
阅读 30
收藏 0
点赞 0
评论 0
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);
}
XLoggerTest.java 文件源码
项目:bartleby
阅读 26
收藏 0
点赞 0
评论 0
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);
}
LoggedAction.java 文件源码
项目:clustercode
阅读 22
收藏 0
点赞 0
评论 0
public LoggedAction withName(Class name) {
this.log = XLoggerFactory.getXLogger(name);
return this;
}