當前位置: 首頁>>代碼示例>>Java>>正文


Java JoranConfigurator類代碼示例

本文整理匯總了Java中ch.qos.logback.classic.joran.JoranConfigurator的典型用法代碼示例。如果您正苦於以下問題:Java JoranConfigurator類的具體用法?Java JoranConfigurator怎麽用?Java JoranConfigurator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JoranConfigurator類屬於ch.qos.logback.classic.joran包,在下文中一共展示了JoranConfigurator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testUdpSender

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的package包/類
@Test
public void testUdpSender() 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-udp.xml"));

  Logger logger = context.getLogger("test-udp");
  logger.info("test message over udp");

  context.stop();
  Thread.sleep(100);

  final String serverData = serverStream.toString();
  assertTrue("Server received: " + serverData, serverData.contains("test message over udp"));
}
 
開發者ID:serioussam,項目名稱:syslogappender,代碼行數:18,代碼來源:SyslogAppenderTest.java

示例2: initializeLogback

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的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

示例3: load

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的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

示例4: initLog

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的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

示例5: testTcpSender

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的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

示例6: testTlsSender

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的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

示例7: captureOutput

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的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

示例8: writeLogsOnFileAndConsole

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的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: initializeLogging

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的package包/類
private void initializeLogging() {
    String graviteeHome = System.getProperty("gravitee.home");
    String logbackConfiguration = graviteeHome + File.separator + "config" + File.separator + "logback.xml";
    File logbackConfigurationfile = new File(logbackConfiguration);

    // If logback configuration available, load it, else, load default logback configuration
    if (logbackConfigurationfile.exists()) {
        System.setProperty("logback.configurationFile", logbackConfigurationfile.getAbsolutePath());
        StaticLoggerBinder loggerBinder = StaticLoggerBinder.getSingleton();
        LoggerContext loggerContext = (LoggerContext) loggerBinder.getLoggerFactory();
        loggerContext.reset();
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(loggerContext);
        try {
            configurator.doConfigure(logbackConfigurationfile);
        } catch( JoranException e ) {
            e.printStackTrace();
        }

        // Internal status data is printed in case of warnings or errors.
        StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
    }
}
 
開發者ID:gravitee-io,項目名稱:graviteeio-access-management,代碼行數:24,代碼來源:Container.java

示例10: load

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的package包/類
public void load(File... configList) throws JoranException {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    for (File config : configList) {
        if (config.exists()) {
            if (config.isFile()) {
                if (config.canRead()) {
                    JoranConfigurator configurator = new JoranConfigurator();
                    configurator.setContext(context);

                    // 設定をクリアして再読み込み
                    context.reset();
                    configurator.doConfigure(config);
                    LOG.warn("logback設定ファイル再設定が完了しました。{}", config.getAbsolutePath());
                    break;
                } else {
                    LOG.warn("logback設定ファイルが読み込めません。{}", config.getAbsolutePath());
                }
            } else {
                LOG.warn("logback設定ファイルがディレクトリです。{}", config.getAbsolutePath());
            }
        } else {
            LOG.info("logback設定ファイルが見つかりません。{}", config.getAbsolutePath());
        }
    }
}
 
開發者ID:otsecbsol,項目名稱:linkbinder,代碼行數:26,代碼來源:LogbackConfigurationLoader.java

示例11: contextInitialized

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的package包/類
/**
 * 服務容器啟動初始化加加載日誌文件
 * @param servletContextEvent
 */
public void contextInitialized(ServletContextEvent servletContextEvent) {
    //係統啟動加載日誌配置文件
    InputStream is = this.getClass().getResourceAsStream("/logback.xml");
    try {
        LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(lc);
        lc.reset();
        configurator.doConfigure(is);
    } catch (Exception e) {
        e.printStackTrace();
        logger.error("加載logback.xml 日誌配置文件加載異常...",e);
        System.exit(0);
    }

    logger.debug(">>> Web :: 容器初始化完成 Success!");
}
 
開發者ID:blogshun,項目名稱:ants-project,代碼行數:22,代碼來源:WebContextListener.java

示例12: initializeLogback

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的package包/類
private void initializeLogback() {
    Path logbackFilePath = Paths.get(configPath, "logback.xml");
    if (logbackFilePath.toFile().exists()) {
        try {
            // Load logback configuration
            LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
            context.reset();
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(context);
            configurator.doConfigure(logbackFilePath.toFile());

            // Install java.util.logging bridge
            SLF4JBridgeHandler.removeHandlersForRootLogger();
            SLF4JBridgeHandler.install();
        } catch (JoranException e) {
            throw new GossipInitializeException("Misconfiguration on logback.xml, check it.", e);
        }
    }
}
 
開發者ID:syhily,項目名稱:gossip,代碼行數:20,代碼來源:GossipLogModule.java

示例13: configureLogger

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的package包/類
private static void configureLogger(String logDir, String logLevel, String logbackConf) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    try {
        JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(context);
        context.reset();
        if (!logDir.endsWith(File.separator))
            logDir+= File.separator;
        context.putProperty("LOG_DIR", logDir);
        context.putProperty("LOG_LEVEL", logLevel);

        InputStream is = classloader.getResourceAsStream(logbackConf);
        configurator.doConfigure(is);
    } catch (JoranException je) {
        LOG.warn("Cannot configure logger. Continue to execute the command.", je);
    }
    StatusPrinter.printInCaseOfErrorsOrWarnings(context);
}
 
開發者ID:porunov,項目名稱:acme_client,代碼行數:19,代碼來源:Application.java

示例14: onApplicationEvent

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的package包/類
@Override
public void onApplicationEvent(ApplicationEvent event) {
    final String settings = environment.getProperty("logging.config.src");
    if (StringUtils.hasText(settings)) {
        try {
            final ContextBase context = (ContextBase) StaticLoggerBinder.getSingleton().getLoggerFactory();
            final JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(context);
            LOG.info("try to update logback configuration to {}", settings);
            context.reset();
            configurator.doConfigure(new ByteArrayInputStream(settings.getBytes()));
        } catch (JoranException e) {
            LOG.error("can't load settings", e);
        }
    }
}
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:17,代碼來源:LogbackConfigurationListener.java

示例15: loadLoggerConfiguration

import ch.qos.logback.classic.joran.JoranConfigurator; //導入依賴的package包/類
/**
 * Loads the Logback configuration from a resource file.
 * Only here to avoid polluting other examples with logs. Could be
 * replaced by a simple logback.xml file in the resource folder.
 */
private static void loadLoggerConfiguration() {
    LoggerContext context = (LoggerContext) LoggerFactory
            .getILoggerFactory();
    context.reset();

    JoranConfigurator configurator = new JoranConfigurator();
    configurator.setContext(context);
    try {
        if (LOGBACK_CONF_FILE != null) {
            configurator.doConfigure(LOGBACK_CONF_FILE);
        }
    } catch (JoranException e) {
        Logger.getLogger(MainTrader.class.getName()).log(Level.SEVERE,
                "Unable to load Logback configuration", e);
    }
}
 
開發者ID:KosherBacon,項目名稱:JavaBitcoinTrader,代碼行數:22,代碼來源:MainTrader.java


注:本文中的ch.qos.logback.classic.joran.JoranConfigurator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。