當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。