Java Code Examples for org.apache.logging.log4j.core.config.LoggerConfig#getLevel()
The following examples show how to use
org.apache.logging.log4j.core.config.LoggerConfig#getLevel() .
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: Log4JController.java From GreenSummer with GNU Lesser General Public License v2.1 | 6 votes |
/** * Frees the given logger from the appender used to be displayed directly by this controller. * * @param name the name * @return the response entity */ @RequestMapping(value = "free/{name}/", produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET, headers = "Accept=application/json") @ResponseBody public ResponseEntity<LogResponse> free(@PathVariable("name") final String name) { final LoggerContext ctx = (LoggerContext) LogManager.getContext(false); synchronized (ctx) { final Configuration config = ctx.getConfiguration(); LoggerConfig loggerConfig = config.getLoggerConfig(name); if (name.equalsIgnoreCase(loggerConfig.getName())) { config.removeLogger(name); LoggerConfig newloggerConfig = new LoggerConfig(name, loggerConfig.getLevel(), true); config.addLogger(name, newloggerConfig); } ctx.updateLoggers(); } return new ResponseEntity<>(listLoggers(ctx), HttpStatus.OK); }
Example 2
Source File: LogTestRule.java From ArchUnit with Apache License 2.0 | 6 votes |
public void watch(Class<?> loggerClass, Level level) { this.loggerClass = loggerClass; Appender appender = new AbstractAppender(APPENDER_NAME, null, PatternLayout.createDefaultLayout()) { @Override public void append(LogEvent event) { logEvents.add(new RecordedLogEvent(event)); } }; appender.start(); final LoggerContext ctx = getLoggerContext(); LoggerConfig loggerConfig = ctx.getConfiguration().getLoggerConfig(loggerClass.getName()); oldLevel = loggerConfig.getLevel(); loggerConfig.setLevel(level); loggerConfig.addAppender(appender, level, null); ctx.updateLoggers(); }
Example 3
Source File: LoggerTest.java From feign-reactive with Apache License 2.0 | 5 votes |
private static Level setLogLevel(Level logLevel) { LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false); Configuration configuration = loggerContext.getConfiguration(); LoggerConfig loggerConfig = configuration.getLoggerConfig(LOGGER_NAME); Level previousLevel = loggerConfig.getLevel(); loggerConfig.setLevel(logLevel); loggerContext.updateLoggers(); return previousLevel; }
Example 4
Source File: Log4j2Helper.java From arthas with Apache License 2.0 | 5 votes |
private static Map<String, Object> doGetLoggerInfo(LoggerConfig loggerConfig) { Map<String, Object> info = new HashMap<String, Object>(); String name = loggerConfig.getName(); if (name == null || name.trim().isEmpty()) { name = LoggerConfig.ROOT; } info.put(LoggerHelper.name, name); info.put(LoggerHelper.clazz, loggerConfig.getClass()); CodeSource codeSource = loggerConfig.getClass().getProtectionDomain().getCodeSource(); if (codeSource != null) { info.put(LoggerHelper.codeSource, codeSource.getLocation()); } Object config = getConfigField(loggerConfig); if (config != null) { info.put(LoggerHelper.config, config); } info.put(LoggerHelper.additivity, loggerConfig.isAdditive()); Level level = loggerConfig.getLevel(); if (level != null) { info.put(LoggerHelper.level, level.toString()); } List<Map<String, Object>> result = doGetLoggerAppenders(loggerConfig); info.put(LoggerHelper.appenders, result); return info; }
Example 5
Source File: Logger.java From logging-log4j2 with Apache License 2.0 | 5 votes |
public PrivateConfig(final PrivateConfig pc, final LoggerConfig lc) { this.config = pc.config; this.loggerConfig = lc; this.loggerConfigLevel = lc.getLevel(); this.intLevel = this.loggerConfigLevel.intLevel(); this.logger = pc.logger; this.requiresLocation = this.loggerConfig.requiresLocation(); }
Example 6
Source File: Nukkit.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public static Level getLogLevel() { LoggerContext ctx = (LoggerContext) LogManager.getContext(false); Configuration log4jConfig = ctx.getConfiguration(); LoggerConfig loggerConfig = log4jConfig.getLoggerConfig(org.apache.logging.log4j.LogManager.ROOT_LOGGER_NAME); return loggerConfig.getLevel(); }