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