当前位置: 首页>>代码示例>>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;未经允许,请勿转载。