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


Java JoranConfigurator.doConfigure方法代码示例

本文整理汇总了Java中ch.qos.logback.classic.joran.JoranConfigurator.doConfigure方法的典型用法代码示例。如果您正苦于以下问题:Java JoranConfigurator.doConfigure方法的具体用法?Java JoranConfigurator.doConfigure怎么用?Java JoranConfigurator.doConfigure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ch.qos.logback.classic.joran.JoranConfigurator的用法示例。


在下文中一共展示了JoranConfigurator.doConfigure方法的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: 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

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: 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

示例15: main

import ch.qos.logback.classic.joran.JoranConfigurator; //导入方法依赖的package包/类
public static void main(String[] args)  {
  Logger logger = LoggerFactory
      .getLogger(GoMDC.class);
  LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

  try {
    JoranConfigurator configurator = new JoranConfigurator();
    configurator.setContext(lc);
    lc.reset();
    configurator.doConfigure("mdcFilter.xml");
    
  } catch (JoranException je) {
    StatusPrinter.print(lc);
  }

  logger.debug("I know me " + 0);
  MDC.put("key", "val");
  logger.debug("I know me " + 1);
  
  StatusPrinter.print(lc);
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:22,代码来源:GoMDC.java


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