本文整理汇总了Java中org.slf4j.ext.XLoggerFactory类的典型用法代码示例。如果您正苦于以下问题:Java XLoggerFactory类的具体用法?Java XLoggerFactory怎么用?Java XLoggerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XLoggerFactory类属于org.slf4j.ext包,在下文中一共展示了XLoggerFactory类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.slf4j.ext.XLoggerFactory; //导入依赖的package包/类
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();
}
示例2: testEntering
import org.slf4j.ext.XLoggerFactory; //导入依赖的package包/类
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)");
}
示例3: testExiting
import org.slf4j.ext.XLoggerFactory; //导入依赖的package包/类
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)");
}
示例4: testThrowing
import org.slf4j.ext.XLoggerFactory; //导入依赖的package包/类
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);
}
示例5: testCaught
import org.slf4j.ext.XLoggerFactory; //导入依赖的package包/类
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);
}
示例6: withName
import org.slf4j.ext.XLoggerFactory; //导入依赖的package包/类
public LoggedAction withName(Class name) {
this.log = XLoggerFactory.getXLogger(name);
return this;
}