當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。