当前位置: 首页>>代码示例>>Java>>正文


Java LoggerContext.reset方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:geeker-lait,项目名称:tasfe-framework,代码行数:17,代码来源:InitLogback.java

示例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);
            }
        }
    }
}
 
开发者ID:CodeDogDream,项目名称:CampusHelp,代码行数:23,代码来源:LogBackConfigLoader.java

示例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);
    }
}
 
开发者ID:HujiangTechnology,项目名称:Juice,代码行数:22,代码来源:LogInitUtil.java

示例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"));
}
 
开发者ID:serioussam,项目名称:syslogappender,代码行数:18,代码来源:SyslogAppenderTest.java

示例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"));
}
 
开发者ID:serioussam,项目名称:syslogappender,代码行数:18,代码来源:SyslogAppenderTest.java

示例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);
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:17,代码来源:AbstractLoggingTestSuite.java

示例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();
}
 
开发者ID:BatchLabs,项目名称:escalog,代码行数:20,代码来源:LogFmtTest.java

示例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);
      } 
  }
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:23,代码来源:LogFactory.java

示例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());
        }
    }
}
 
开发者ID:talentchain,项目名称:talchain,代码行数:16,代码来源:AdvancedDeviceUtils.java

示例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);
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:10,代码来源:LogbackTest.java

示例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");
}
 
开发者ID:lirenzuo,项目名称:rocketmq-rocketmq-all-4.1.0-incubating,代码行数:13,代码来源:MQAdminStartup.java

示例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);
}
 
开发者ID:reddr,项目名称:LibScout,代码行数:28,代码来源:TplCLI.java

示例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");
}
 
开发者ID:y123456yz,项目名称:reading-and-annotate-rocketmq-3.4.6,代码行数:10,代码来源:MQAdminStartup.java

示例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;
    }
}
 
开发者ID:aro,项目名称:app-logbrowser,代码行数:29,代码来源:LogHelper.java

示例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);
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:14,代码来源:StandaloneTestUtils.java


注:本文中的ch.qos.logback.classic.LoggerContext.reset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。