本文整理匯總了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);
}
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}
}
示例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);
}
}
示例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...");
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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.");
}
示例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);
}