本文整理汇总了Java中ch.qos.logback.classic.LoggerContext.reset方法的典型用法代码示例。如果您正苦于以下问题:Java LoggerContext.reset方法的具体用法?Java LoggerContext.reset怎么用?Java LoggerContext.reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ch.qos.logback.classic.LoggerContext
的用法示例。
在下文中一共展示了LoggerContext.reset方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializeLogback
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
@PostConstruct
public void initializeLogback() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
InputStream is = InitLogback.class.getClassLoader().getResourceAsStream("tasfe-logback.xml");
if (is == null)
return;
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
try {
configurator.doConfigure(is);
} catch (JoranException e) {
e.printStackTrace();
}
}
示例2: load
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
public static void load(String externalConfigFileLocation) throws IOException, JoranException {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
File externalConfigFile = new File(externalConfigFileLocation);
if (!externalConfigFile.exists()) {
throw new IOException("Logback External Config File Parameter does not reference a file that exists");
} else {
if (!externalConfigFile.isFile()) {
throw new IOException("Logback External Config File Parameter exists, but does not reference a file");
} else {
if (!externalConfigFile.canRead()) {
throw new IOException("Logback External Config File exists and is a file, but cannot be read.");
} else {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(externalConfigFileLocation);
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
}
}
}
示例3: initLog
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
public static void initLog() {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator jc = new JoranConfigurator();
jc.setContext(context);
context.reset();
String env = System.getProperty("system.environment");
if(StringUtils.isBlank(env)) {
System.err.println("get system.environment error");
throw new RuntimeException("can't get env, service stop!");
}
URL tmpConfigFIleStr = Startup.class.getResource("/logback-" + env + ".xml");
try {
System.out.println("start with configFile : " + tmpConfigFIleStr);
jc.doConfigure(tmpConfigFIleStr);
log.info("load logback config --> " + tmpConfigFIleStr.getFile());
} catch (JoranException e) {
System.err.println(tmpConfigFIleStr + " not exist");
throw new RuntimeException(e);
}
}
示例4: testTcpSender
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
@Test
public void testTcpSender() throws JoranException, InterruptedException {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
context.reset();
configurator.doConfigure(this.getClass().getClassLoader().getResourceAsStream("logback-syslog-tcp.xml"));
Logger logger = context.getLogger("test-tcp");
logger.info("test message over tcp");
context.stop();
Thread.sleep(100);
final String serverData = serverStream.toString();
assertTrue("Server received: " + serverData, serverData.contains("test message over tcp"));
}
示例5: testTlsSender
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
@Test
public void testTlsSender() throws JoranException, InterruptedException {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
context.reset();
configurator.doConfigure(this.getClass().getClassLoader().getResourceAsStream("logback-syslog-tls.xml"));
Logger logger = context.getLogger("test-tls");
logger.info("test message over tls");
context.stop();
Thread.sleep(100);
final String serverData = serverStream.toString();
assertTrue("Server received: " + serverData, serverData.contains("test message over tls"));
}
示例6: captureOutput
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
protected void captureOutput() throws IOException, JoranException {
System.setProperty("ROOT_APPENDER", "JSON_CONSOLE");
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
loggerContext.reset();
JoranConfigurator configurator = new JoranConfigurator();
InputStream configStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("logback.xml");
configurator.setContext(loggerContext);
configurator.doConfigure(configStream);
configStream.close();
baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
System.setOut(ps);
}
示例7: 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();
}
示例8: 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);
}
}
示例9: adjustDetailedTracing
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
public static void adjustDetailedTracing(SystemProperties config, long blockNum) {
// here we can turn on the detail tracing in the middle of the chain
if (blockNum >= config.traceStartBlock() && config.traceStartBlock() != -1) {
final URL configFile = ClassLoader.getSystemResource("logback-detailed.xml");
final LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
final ContextInitializer ci = new ContextInitializer(loggerContext);
loggerContext.reset();
try {
ci.configureByResource(configFile);
} catch (Exception e) {
System.out.println("Error applying new config " + e.getMessage());
}
}
}
示例10: init
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
@Before
public void init() throws JoranException {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(new File("src/test/resources/logback-example.xml"));
StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
示例11: initLogback
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
private static void initLogback() throws JoranException {
// String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
String rocketmqHome = "D:\\\\eclipse-workspace\\\\rocketmq-rocketmq-all-4.1.0-incubating\\\\rocketmq-rocketmq-all-4.1.0-incubating\\\\distribution";
// 初始化Logback
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(rocketmqHome + "/conf/logback_tools.xml");
}
示例12: initLogging
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
private static void initLogging() {
LoggerContext context = (LoggerContext) org.slf4j.LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
context.reset(); // clear any previous configuration
configurator.doConfigure("./logging/logback.xml");
ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
switch (CliOptions.logType) {
case CONSOLE:
rootLogger.detachAppender("FILE");
break;
case FILE:
rootLogger.detachAppender("CONSOLE");
break;
case NONE:
rootLogger.detachAndStopAllAppenders();
break;
}
} catch (JoranException je) {
// StatusPrinter will handle this
}
StatusPrinter.printInCaseOfErrorsOrWarnings(context);
}
示例13: initLogback
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
private static void initLogback() throws JoranException {
String rocketmqHome = System.getProperty(MixAll.ROCKETMQ_HOME_PROPERTY, System.getenv(MixAll.ROCKETMQ_HOME_ENV));
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
configurator.doConfigure(rocketmqHome + "/conf/logback_tools.xml");
}
示例14: getLogFromLogback
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
private static Path getLogFromLogback( final File logbackConfig )
{
try
{
LoggerContext loggerContext = new LoggerContext();
JoranConfigurator jc = new JoranConfigurator();
jc.setContext( loggerContext );
loggerContext.reset();
jc.doConfigure( logbackConfig );
for ( Logger logger : loggerContext.getLoggerList() )
{
for ( Iterator<Appender<ILoggingEvent>> index = logger.iteratorForAppenders(); index.hasNext(); )
{
Appender<ILoggingEvent> appender = index.next();
if ( appender instanceof FileAppender )
{
return Paths.get( ( (FileAppender) appender ).getFile() );
}
}
}
return null;
}
catch ( Exception e )
{
return null;
}
}
示例15: reloadLogback
import ch.qos.logback.classic.LoggerContext; //导入方法依赖的package包/类
public static void reloadLogback(String configFile) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
try {
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(context);
context.reset();
configurator.doConfigure(configFile);
} catch (JoranException je) {
// StatusPrinter will handle this.
}
StatusPrinter.printInCaseOfErrorsOrWarnings(context);
}