Java Code Examples for ch.qos.logback.classic.Logger#warn()
The following examples show how to use
ch.qos.logback.classic.Logger#warn() .
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: LogBackHookProxy.java From uavstack with Apache License 2.0 | 5 votes |
/** * figure out the logback's configuration: for example, appenders' file path, buff io, etc... * * @param context * @param webapploader */ private void figureOutLogBackConfig(HookContext context, ClassLoader webapploader) { org.slf4j.Logger slflogger = LoggerFactory.getLogger(LogBackHookProxy.class); if (!(slflogger instanceof Logger)) { return; } Logger logback = (Logger) slflogger; InterceptContext interceptContext = (InterceptContext) context.get(HookConstants.INTERCEPTCONTEXT); if (interceptContext == null) { logback.warn("No InterceptContext available, can't figure out LogBack configuration."); return; } @SuppressWarnings("unchecked") LinkedList<LogProfileInfo> list = (LinkedList<LogProfileInfo>) interceptContext .get(HookConstants.LOG_PROFILE_LIST); if (null == list) { list = new LinkedList<LogProfileInfo>(); interceptContext.put(HookConstants.LOG_PROFILE_LIST, list); } String appid = (String) (interceptContext.get(InterceptConstants.CONTEXTPATH)); // figureour all loggers LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory(); List<ch.qos.logback.classic.Logger> loggers = loggerContext.getLoggerList(); for (Logger logger : loggers) { figureoutLogConfiguration(logger, list, appid); } }
Example 2
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."); } }
Example 3
Source File: LogbackIntegrationTest.java From tutorials with MIT License | 5 votes |
@Test public void givenConfig_MessageFiltered() { Logger foobar = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("com.baeldung.foobar"); Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("com.baeldung.logback"); Logger testslogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger("com.baeldung.logback.tests"); foobar.debug("This is logged from foobar"); logger.debug("This is not logged from logger"); logger.info("This is logged from logger"); testslogger.info("This is not logged from tests"); testslogger.warn("This is logged from tests"); }
Example 4
Source File: LogbackLoggerResource.java From micro-server with Apache License 2.0 | 4 votes |
private void changeLevel(Logger logger, Level newLevel) { logger.warn("Changing logging level from " + logger.getLevel() + " to " + newLevel); logger.setLevel(newLevel); }