本文整理汇总了Java中ch.qos.logback.classic.LoggerContext.start方法的典型用法代码示例。如果您正苦于以下问题:Java LoggerContext.start方法的具体用法?Java LoggerContext.start怎么用?Java LoggerContext.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.classic.LoggerContext
的用法示例。
在下文中一共展示了LoggerContext.start方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
@Before
public void init()
{
LoggerContext ctx = (LoggerContext) LoggerFactory.getILoggerFactory();
ctx.reset();
this.layoutProducer = new LayoutProducer();
ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
appender.setLayout(layoutProducer);
appender.setContext(ctx);
appender.start();
Logger basicLogger = ctx.getLogger(LogFmtTest.class);
basicLogger.addAppender(appender);
this.logger = LogFmt.from(basicLogger);
ctx.start();
}
示例2: writeLogsOnFileAndConsole
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
private void writeLogsOnFileAndConsole() {
loggers.debug("****Configuring Logger****");
try {
if(Platform.isRunning()){
System.setProperty(HYDROGRAPH_INSTALLATION_LOCATION, Platform.getInstallLocation().getURL().getPath());
ClassLoader loader = new URLClassLoader(new URL[]
{new File(Platform.getInstallLocation().getURL().getPath() + LOG_DIR).toURI().toURL()});
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
URL url = Loader.getResource(CLASSIC_FILE, loader);
if (url != null) {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(url);
lc.start();
}
loggers.debug("****Logger Configured Successfully****");
}
} catch(MalformedURLException|JoranException exception){
loggers.error("Failed to configure the logger {}", exception);
}
}