當前位置: 首頁>>代碼示例>>Java>>正文


Java StatusPrinter.printInCaseOfErrorsOrWarnings方法代碼示例

本文整理匯總了Java中ch.qos.logback.core.util.StatusPrinter.printInCaseOfErrorsOrWarnings方法的典型用法代碼示例。如果您正苦於以下問題:Java StatusPrinter.printInCaseOfErrorsOrWarnings方法的具體用法?Java StatusPrinter.printInCaseOfErrorsOrWarnings怎麽用?Java StatusPrinter.printInCaseOfErrorsOrWarnings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ch.qos.logback.core.util.StatusPrinter的用法示例。


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

示例6: readAndSetLogbackConfiguration

import ch.qos.logback.core.util.StatusPrinter; //導入方法依賴的package包/類
private static boolean readAndSetLogbackConfiguration(String filePath, String fileName) {
    
    boolean doesConfigFileExist = FileIo.doesFileExist(filePath, fileName);
    
    if (doesConfigFileExist) {
        File logggerConfigFile = new File(filePath + File.separator + fileName);

        LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();

        try {
            JoranConfigurator configurator = new JoranConfigurator();
            configurator.setContext(context);
            context.reset(); 
            configurator.doConfigure(logggerConfigFile);
            StatusPrinter.printInCaseOfErrorsOrWarnings(context);
            return true;
        } 
        catch (Exception e) {
            StatusPrinter.printInCaseOfErrorsOrWarnings(context);
            return false;
        }
    }
    else {
        return false;
    }
}
 
開發者ID:PearsonEducation,項目名稱:StatsPoller,代碼行數:27,代碼來源:Driver.java

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

示例8: main

import ch.qos.logback.core.util.StatusPrinter; //導入方法依賴的package包/類
public static void main(String[] args) {

    Logger logger = LoggerFactory.getLogger(SampleLogging.class);
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();

    try {
      JoranConfigurator configurator = new JoranConfigurator();
      lc.reset();
      configurator.setContext(lc);
      configurator.doConfigure(args[0]);
    } catch (JoranException je) {
      // StatusPrinter will handle this
    }
    StatusPrinter.printInCaseOfErrorsOrWarnings(lc);

    logger.debug("Everything's going well");
    logger.error("maybe not quite...");
  }
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:19,代碼來源:SampleLogging.java

示例9: initLogging

import ch.qos.logback.core.util.StatusPrinter; //導入方法依賴的package包/類
/**
 * Initialize logback from the given file.
 *
 * @param location
 *            the location of the config file: either a "classpath:"
 *            location (e.g. "classpath:logback.xml"), an absolute file URL
 *            (e.g. "file:C:/logback.xml), or a plain absolute path in the
 *            file system (e.g. "C:/logback.xml")
 * @throws java.io.FileNotFoundException
 *             if the location specifies an invalid file path
 */
public static void initLogging(final String location)
		throws FileNotFoundException {
	String resolvedLocation = SystemPropertyUtils.resolvePlaceholders(location);
	URL url = ResourceUtils.getURL(resolvedLocation);
	LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

	try {
		JoranConfigurator configurator = new JoranConfigurator();
		configurator.setContext(loggerContext);
		// the context was probably already configured by default
		// configuration
		// rules
		loggerContext.reset();
		configurator.doConfigure(url);
	} catch (JoranException je) {
		// StatusPrinter will handle this
	}
	StatusPrinter.printInCaseOfErrorsOrWarnings(loggerContext);
}
 
開發者ID:RBGKew,項目名稱:eMonocot,代碼行數:31,代碼來源:LogbackConfigurer.java

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

示例11: start

import ch.qos.logback.core.util.StatusPrinter; //導入方法依賴的package包/類
public void start(BundleContext context) {
  LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
  
  try {
    JoranConfigurator configurator = new JoranConfigurator();
    configurator.setContext(lc);
    // the context was probably already configured by default configuration 
    // rules
    lc.reset(); 
    configurator.doConfigure("src/test/input/osgi/simple.xml");
  } catch (JoranException je) {
     je.printStackTrace();
  }
  StatusPrinter.printInCaseOfErrorsOrWarnings(lc);

  
  Logger logger = LoggerFactory.getLogger(this.getClass());
  logger.info("Activator.start()");
  m_context = context;
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:21,代碼來源:Activator.java

示例12: configureLogging

import ch.qos.logback.core.util.StatusPrinter; //導入方法依賴的package包/類
/**
 * Set the correct logback configuration file based on the classname of the
 * caller class.
 */
public static void configureLogging() {
    final LogConfigurationHelper helper = new LogConfigurationHelper();
    final Class<?> clazz = helper.getCallerClass();
    final String filename = "/" + clazz.getSimpleName() + "_logback.xml";

    final URL location = clazz.getResource(filename);
    final LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    try {
        final JoranConfigurator configurator = new JoranConfigurator();
        configurator.setContext(context);
        context.reset();
        configurator.doConfigure(location);
    }
    catch (final JoranException je) {
        // do nothing, it will be handled by StatusPrinter
    }
    StatusPrinter.printInCaseOfErrorsOrWarnings(context);
}
 
開發者ID:MSG134,項目名稱:IVCT_Framework,代碼行數:23,代碼來源:LogConfigurationHelper.java

示例13: main

import ch.qos.logback.core.util.StatusPrinter; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {

    Context context = new ContextBase();

    Map<ElementSelector, Action> ruleMap = new HashMap<ElementSelector, Action>();

    // we start with the rule for the top-most (root) element
    ruleMap.put(new ElementSelector("*/computation"), new ComputationAction1());

    // Associate "/new-rule" pattern with NewRuleAction from the
    // org.apache.joran.action package.
    // 
    // We will let the XML file to teach the Joran interpreter about new rules
    ruleMap.put(new ElementSelector("/computation/newRule"), new NewRuleAction());

    SimpleConfigurator simpleConfigurator = new SimpleConfigurator(ruleMap);
    // link the configurator with its context
    simpleConfigurator.setContext(context);

    simpleConfigurator.doConfigure(args[0]);

    // Print any errors that might have occured.
    StatusPrinter.printInCaseOfErrorsOrWarnings(context);
  }
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:25,代碼來源:NewRuleCalculator.java

示例14: main

import ch.qos.logback.core.util.StatusPrinter; //導入方法依賴的package包/類
public static void main(String[] args) {
  // 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(args[0]);
  } catch (JoranException je) {
    // StatusPrinter will handle this
  }
  StatusPrinter.printInCaseOfErrorsOrWarnings(context);

  logger.info("Entering application.");

  Foo foo = new Foo();
  foo.doIt();
  logger.info("Exiting application.");
}
 
開發者ID:cscfa,項目名稱:bartleby,代碼行數:23,代碼來源:MyApp3.java

示例15: init

import ch.qos.logback.core.util.StatusPrinter; //導入方法依賴的package包/類
@Before
public void init() throws JoranException {
    LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    JoranConfigurator configurator = new JoranConfigurator();
    configurator.setContext(lc);
    lc.reset();
    configurator.doConfigure(new File("src/test/resources/logback-example.xml"));
    StatusPrinter.printInCaseOfErrorsOrWarnings(lc);
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:10,代碼來源:LogbackTest.java


注:本文中的ch.qos.logback.core.util.StatusPrinter.printInCaseOfErrorsOrWarnings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。