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