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


Java StatusPrinter类代码示例

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


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

示例1: load

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

示例2: initializeLogging

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

示例3: init

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

示例4: configureLogger

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

示例5: checkSanity

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的package包/类
static void checkSanity(Auditor auditor) throws AuditException {
    StatusManager sm = auditor.getStatusManager();

    if (getHighestLevel(0, sm) > Status.INFO) {
        StatusPrinter.print(sm);
    }

    if (auditor.getClientApplication() == null) {
        throw new AuditException("Client application has not been set");
    }

    if (auditor.getAuditAppender() == null) {
        throw new AuditException("No audit appender. Please see "
                + NULL_AUDIT_APPENDER_URL);
    }
}
 
开发者ID:bhits,项目名称:common-libraries,代码行数:17,代码来源:ImprovedAuditorFactory.java

示例6: configureLogbackFromLocalFile

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的package包/类
private static void configureLogbackFromLocalFile() {
	boolean localLogFileExists = Files.exists(Paths.get("./logback.xml"));
	if (!localLogFileExists) {
		System.out.println("logback.xml not found in local path - defaulting to packaged one");
		return;
	}
	
	// assume SLF4J is bound to logback in the current environment
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    
    try {
      JoranConfigurator configurator = new JoranConfigurator();
      configurator.setContext(context);
      // Call context.reset() to clear any previous configuration, e.g. default 
      // configuration. For multi-step configuration, omit calling context.reset().
      context.reset();
      configurator.doConfigure("./logback.xml");
    } catch (JoranException je) {
      // StatusPrinter will handle this
    }
    StatusPrinter.printInCaseOfErrorsOrWarnings(context);		
	
}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:24,代码来源:GuiUtil.java

示例7: configureLogging

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的package包/类
public static void configureLogging() {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    try {
        JoranConfigurator configurator = new JoranConfigurator();
        context.reset();
        configurator.setContext(context);
        System.out.println("Attempting to load logback configuration file: " + LOG_CONFIG_FILE_NAME
                            + " from classpath or " + System.getProperty("user.home") + "/.waltz/");

        Resource logbackConfigFile = IOUtilities.getFileResource(LOG_CONFIG_FILE_NAME);
        if (logbackConfigFile.exists()) {
            System.out.println("Found logback configuration file at: " + logbackConfigFile.getFile().getAbsolutePath());
            configurator.doConfigure(logbackConfigFile.getFile());
        } else {
            System.out.println("Logback configuration file not found..");
        }
    } catch (IOException | JoranException e) {
        // StatusPrinter will handle this
    }
    StatusPrinter.printInCaseOfErrorsOrWarnings(context);
}
 
开发者ID:khartec,项目名称:waltz,代码行数:22,代码来源:LoggingUtilities.java

示例8: initializeLogging

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的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 ) {
            LoggerFactory.getLogger(Container.class).error("An error occurs while initializing logging system", e);
        }

        // Internal status data is printed in case of warnings or errors.
        StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
    }
}
 
开发者ID:gravitee-io,项目名称:gravitee-gateway,代码行数:24,代码来源:Container.java

示例9: stopTimeBasedRollingPolicy

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的package包/类
@Test
public void stopTimeBasedRollingPolicy() {
  rfa.setContext(context);

  tbrp.setFileNamePattern(CoreTestConstants.OUTPUT_DIR_PREFIX + "toto-%d.log.zip");
  tbrp.start();
  rfa.setRollingPolicy(tbrp);
  rfa.start();

  StatusPrinter.print(context);
  assertTrue(tbrp.isStarted());
  assertTrue(rfa.isStarted());
  rfa.stop();
  assertFalse(rfa.isStarted());
  assertFalse(tbrp.isStarted());

}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:18,代码来源:RollingFileAppenderTest.java

示例10: failed_rename

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的package包/类
@Test
public void failed_rename() throws IOException {
  if (!EnvUtilForTests.isWindows())
    return;

  FileOutputStream fos = null;
  try {
    String fileName = testId2FileName("failed_rename");
    File file = new File(fileName);
    file.getParentFile().mkdirs();

    fos = new FileOutputStream(fileName);

    String testId = "failed_rename";
    rolloverChecker = new ZRolloverChecker(testId);
    genericTest(testId, "failed_rename", "", FILE_OPTION_SET, NO_RESTART);


  } finally {
    StatusPrinter.print(context);
    if (fos != null) fos.close();
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:24,代码来源:TimeBasedRollingTest.java

示例11: initLogging

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的package包/类
private static void initLogging() throws IOException, JoranException {
	final File logDir = ConfigDir.getInstance().getLogDir();
	DerbyUtil.setLogFile(createFile(logDir, "derby.log"));

	final String logbackXmlName = "logback.client.xml";
	final File logbackXmlFile = createFile(ConfigDir.getInstance().getFile(), logbackXmlName);
	if (!logbackXmlFile.exists()) {
		AppIdRegistry.getInstance().copyResourceResolvingAppId(
				SubShareGui.class, logbackXmlName, logbackXmlFile);
	}

	final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
	try {
	  final JoranConfigurator configurator = new JoranConfigurator();
	  configurator.setContext(context);
	  // Call context.reset() to clear any previous configuration, e.g. default
	  // configuration. For multi-step configuration, omit calling context.reset().
	  context.reset();
	  configurator.doConfigure(logbackXmlFile.getIoFile());
	} catch (final JoranException je) {
		// StatusPrinter will handle this
		doNothing();
	}
	StatusPrinter.printInCaseOfErrorsOrWarnings(context);
}
 
开发者ID:subshare,项目名称:subshare,代码行数:26,代码来源:SubShareGui.java

示例12: doFirstPart

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的package包/类
public List<FruitShell> doFirstPart(String filename) throws Exception {

    try {
      HashMap<ElementSelector, Action> rulesMap = new HashMap<ElementSelector, Action>();
      rulesMap.put(new ElementSelector("group/fruitShell"), new FruitShellAction());
      rulesMap.put(new ElementSelector("group/fruitShell/fruit"),
          new FruitFactoryAction());
      rulesMap.put(new ElementSelector("group/fruitShell/fruit/*"), new NOPAction());
      SimpleConfigurator simpleConfigurator = new SimpleConfigurator(rulesMap);

      simpleConfigurator.setContext(fruitContext);

      simpleConfigurator.doConfigure(CoreTestConstants.TEST_SRC_PREFIX + "input/joran/replay/"
          + filename);

      return fruitContext.getFruitShellList();
    } catch (Exception je) {
      StatusPrinter.print(fruitContext);
      throw je;
    }
  }
 
开发者ID:cscfa,项目名称:bartleby,代码行数:22,代码来源:FruitConfigurationTest.java

示例13: loadLogConfiguration

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的package包/类
private static boolean loadLogConfiguration() { // TODO 抽离加载配置的方法 使系统统一扫描加载
    String logConfigurationPath = System.getProperty("logback.configurationFile");
    if (StringUtils.isBlank(logConfigurationPath)) {
        logConfigurationPath = "conf/logback-tele.xml";
    }
    URL configPath = ClassLoader.getSystemResource(logConfigurationPath);
    if (configPath == null) {
        System.err.println("无可用日志配置,将使用缺省配置");
        return true;
    }
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    JoranConfigurator configurator = new JoranConfigurator();
    configurator.setContext(lc);
    lc.reset();
    try {
        configurator.doConfigure(configPath);
        StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
    } catch (JoranException e) {
        System.err.println("配置日志配置出错");
        return false;
    }
    return true;
}
 
开发者ID:csdbianhua,项目名称:Telemarketer,代码行数:24,代码来源:Context.java

示例14: init

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的package包/类
/**
 * Package access for testing purposes.
 */
void init() {
  try {
    try {
      new ContextInitializer(defaultLoggerContext).autoConfig();
    } catch (JoranException je) {
      Util.report("Failed to auto configure default logger context", je);
    }
    // logback-292
    if(!StatusUtil.contextHasStatusListener(defaultLoggerContext)) {
      StatusPrinter.printInCaseOfErrorsOrWarnings(defaultLoggerContext);
    }
    contextSelectorBinder.init(defaultLoggerContext, KEY);
    initialized = true;
  } catch (Throwable t) {
    // we should never get here
    Util.report("Failed to instantiate [" + LoggerContext.class.getName()
        + "]", t);
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:23,代码来源:StaticLoggerBinder.java

示例15: reloadByURL

import ch.qos.logback.core.util.StatusPrinter; //导入依赖的package包/类
public void reloadByURL(URL url) throws JoranException {
  StatusListenerAsList statusListenerAsList = new StatusListenerAsList();

  addStatusListener(statusListenerAsList);
  addInfo("Resetting context: " + loggerContext.getName());
  loggerContext.reset();
  // after a reset the statusListenerAsList gets removed as a listener
  addStatusListener(statusListenerAsList);

  try {
    JoranConfigurator configurator = new JoranConfigurator();
    configurator.setContext(loggerContext);
    configurator.doConfigure(url);
    addInfo("Context: " + loggerContext.getName() + " reloaded.");
  } finally {
    removeStatusListener(statusListenerAsList);
    if (debug) {
      StatusPrinter.print(statusListenerAsList.getStatusList());
    }
  }
}
 
开发者ID:cscfa,项目名称:bartleby,代码行数:22,代码来源:JMXConfigurator.java


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