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


Java JoranException类代码示例

本文整理汇总了Java中ch.qos.logback.core.joran.spi.JoranException的典型用法代码示例。如果您正苦于以下问题:Java JoranException类的具体用法?Java JoranException怎么用?Java JoranException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JoranException类属于ch.qos.logback.core.joran.spi包,在下文中一共展示了JoranException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testUdpSender

import ch.qos.logback.core.joran.spi.JoranException; //导入依赖的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.core.joran.spi.JoranException; //导入依赖的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.core.joran.spi.JoranException; //导入依赖的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.core.joran.spi.JoranException; //导入依赖的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.core.joran.spi.JoranException; //导入依赖的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.core.joran.spi.JoranException; //导入依赖的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.core.joran.spi.JoranException; //导入依赖的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: testDefaultOutputWithBadException

import ch.qos.logback.core.joran.spi.JoranException; //导入依赖的package包/类
@Test
public void testDefaultOutputWithBadException() throws JoranException, IOException {
    configLogback(LOGBACK_WITH_THREAD);

    String message = "test output with bad exception";

    log.error(message, new InvalidClassException("Class null is invalid"));

    String logger = AbstractLoggingException.class.getCanonicalName();
    String errorClass = InvalidClassException.class.getCanonicalName();
    String message2 = String.format("Bad implementation of '%s' in use", errorClass);

    String output = baos.toString();

    // there must be original log
    assertThat(output).containsPattern(
        DEFAULT_DATE_FORMAT + ERROR + getThreadName() + getLogger() + message + "\n"
    );
    // alongside log about alert level misuse
    assertThat(output).containsPattern(
        DEFAULT_DATE_FORMAT + ERROR + getThreadName() + logger + ":\\d+: \\[P1\\] 0. " + message2 + "\n"
    );
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:24,代码来源:ReformLoggingLayoutTest.java

示例9: testOutputForOptionalErrorValues

import ch.qos.logback.core.joran.spi.JoranException; //导入依赖的package包/类
@Test
public void testOutputForOptionalErrorValues() throws JoranException, IOException {
    configLogback(LOGBACK_WITH_CUSTOM_DATE_FORMAT);

    String message = "test alert level and error code for regular log level";

    log.info(message);
    log.info(message, new DummyP3Exception());

    String timestamp = "\\d{2}-\\d{2}-\\d{4}";
    String logger = this.getClass().getCanonicalName();

    String output = baos.toString();

    assertThat(output).containsPattern(
        timestamp + INFO + logger + ":\\d+: " + message + "\n"
    );
    assertThat(output).containsPattern(
        timestamp + INFO + logger + ":\\d+: \\[P3\\] 0. " + message + "\n"
    );
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:22,代码来源:ReformLoggingLayoutTest.java

示例10: testStacktraceExistsAfterTheLogEntry

import ch.qos.logback.core.joran.spi.JoranException; //导入依赖的package包/类
@Test
public void testStacktraceExistsAfterTheLogEntry() throws JoranException, IOException {
    configLogback(LOGBACK);

    String message = "test stacktrace";

    log.error(message, new DummyP2Exception());

    String logger = this.getClass().getCanonicalName();

    assertThat(baos.toString()).containsPattern(
        DEFAULT_DATE_FORMAT + ERROR + getThreadName() + logger + ":\\d+: \\[P2\\] 0. " + message + "\n"
            + "\tat " + logger + ".testStacktraceExists(.*" + this.getClass().getSimpleName() + ".java:\\d+.*)\n"
    );

    log.error(message, new DummyP2Exception(new ArithmeticException("There is no such operation ':'")));

    assertThat(baos.toString()).containsPattern(
        "Caused by: " + ArithmeticException.class.getCanonicalName() + ": There is no such operation ':'\n"
    );
}
 
开发者ID:hmcts,项目名称:java-logging,代码行数:22,代码来源:ReformLoggingLayoutTest.java

示例11: writeLogsOnFileAndConsole

import ch.qos.logback.core.joran.spi.JoranException; //导入依赖的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

示例12: initializeLogging

import ch.qos.logback.core.joran.spi.JoranException; //导入依赖的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

示例13: init

import ch.qos.logback.core.joran.spi.JoranException; //导入依赖的package包/类
void init() {
    try {
        try {
            (new KonkerContextInitializer(this.defaultLoggerContext)).autoConfig();
        } catch (JoranException var2) {
            Util.report("Failed to auto configure default logger context", var2);
        }

        if(!StatusUtil.contextHasStatusListener(this.defaultLoggerContext)) {
            StatusPrinter.printInCaseOfErrorsOrWarnings(this.defaultLoggerContext);
        }

        this.contextSelectorBinder.init(this.defaultLoggerContext, KEY);
        this.initialized = true;
    } catch (Throwable var3) {
        Util.report("Failed to instantiate [" + LoggerContext.class.getName() + "]", var3);
    }

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:20,代码来源:KonkerStaticLoggerBinder.java

示例14: autoConfig

import ch.qos.logback.core.joran.spi.JoranException; //导入依赖的package包/类
public void autoConfig() throws JoranException {
    KonkerStatusListenerConfigHelper.installIfAsked(this.loggerContext);
    URL url = this.findURLOfDefaultConfigurationFile(true);
    if (url != null) {
        this.configureByResource(url);
    } else {
        KonkerLoggerConfigurator c = (KonkerLoggerConfigurator)
                EnvUtil.loadFromServiceLoader(KonkerLoggerConfigurator.class);
        if (c != null) {
            try {
                c.setContext(this.loggerContext);
                c.configure(this.loggerContext);
            } catch (Exception var4) {
                throw new LogbackException(String.format("Failed to initialize Configurator: %s using ServiceLoader", new Object[]{c != null ? c.getClass().getCanonicalName() : "null"}), var4);
            }
        } else {
            KonkerLoggerBasicConfigurator.configure(this.loggerContext);
        }
    }

}
 
开发者ID:KonkerLabs,项目名称:konker-platform,代码行数:22,代码来源:KonkerContextInitializer.java

示例15: contextInitialized

import ch.qos.logback.core.joran.spi.JoranException; //导入依赖的package包/类
@Override
public void contextInitialized(ServletContextEvent arg0) {
    String dir = getConfigPath();
    LOG.debug("リソースパス:{}", dir);

    if (StringUtils.isEmpty(dir)) {
        LOG.info("リソースパスが定義されていないためデフォルトのログ出力設定を使用します");
        return;
    }

    try {
        new LogbackConfigurationLoader().load(
                Paths.get(dir, "logback.xml").toFile(),
                Paths.get(dir, "logback.groovy").toFile());
    } catch (JoranException e) {
        LOG.warn("ログ出力設定に失敗しました。デフォルトのログ出力設定を使用します");
    }
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:19,代码来源:LogbackConfigurationInitializeServletContextListener.java


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