Java Code Examples for ch.qos.logback.core.status.Status#ERROR
The following examples show how to use
ch.qos.logback.core.status.Status#ERROR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LogbackLoggingSystem.java From super-cloudops with Apache License 2.0 | 6 votes |
@Override protected void loadConfiguration(LoggingInitializationContext initializationContext, String location, LogFile logFile) { super.loadConfiguration(initializationContext, location, logFile); LoggerContext loggerContext = getLoggerContext(); stopAndReset(loggerContext); try { configureByResourceUrl(initializationContext, loggerContext, ResourceUtils.getURL(location)); } catch (Exception ex) { throw new IllegalStateException("Could not initialize Logback logging from " + location, ex); } List<Status> statuses = loggerContext.getStatusManager().getCopyOfStatusList(); StringBuilder errors = new StringBuilder(); for (Status status : statuses) { if (status.getLevel() == Status.ERROR) { errors.append(errors.length() > 0 ? String.format("%n") : ""); errors.append(status.toString()); } } if (errors.length() > 0) { throw new IllegalStateException(String.format("Logback configuration error detected: %n%s", errors)); } }
Example 2
Source File: BrokerLoggerStatusListener.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Override public void addStatusEvent(Status status) { Throwable throwable = status.getThrowable(); if (status.getEffectiveLevel() == Status.ERROR && _errorClasses.stream().anyMatch(c -> c.isInstance(throwable))) { LOGGER.error("Unexpected error whilst trying to store log entry. Log messages could be lost.", throwable); if (_brokerLogger.getContextValue(Boolean.class, _contextFlag)) { try { _brokerLogger.stopLogging(); _systemConfig.getEventLogger().message(BrokerMessages.FATAL_ERROR( String.format( "Shutting down the broker because context variable '%s' is set and unexpected logging issue occurred: %s", _contextFlag, throwable.getMessage()))); } finally { _systemConfig.closeAsync(); } } } }
Example 3
Source File: RequestContextExportingAppenderTest.java From armeria with Apache License 2.0 | 5 votes |
@AfterEach void tearDown() { final Logger logger = (Logger) LoggerFactory.getLogger(getClass()); final StatusManager sm = rootLogger.getLoggerContext().getStatusManager(); int count = 0; for (Status s : sm.getCopyOfStatusList()) { final int level = s.getEffectiveLevel(); if (level == Status.INFO) { continue; } if (s.getMessage().contains(InternalLoggerFactory.class.getName())) { // Skip the warnings related with Netty. continue; } count++; switch (level) { case Status.WARN: if (s.getThrowable() != null) { logger.warn(s.getMessage(), s.getThrowable()); } else { logger.warn(s.getMessage()); } break; case Status.ERROR: if (s.getThrowable() != null) { logger.warn(s.getMessage(), s.getThrowable()); } else { logger.warn(s.getMessage()); } break; } } if (count > 0) { fail("Appender raised an exception."); } }