use of org.apache.logging.log4j.core.LoggerContext in project spring-boot by spring-projects.
the class Log4J2LoggingSystem method cleanUp.
@Override
public void cleanUp() {
super.cleanUp();
LoggerContext loggerContext = getLoggerContext();
markAsUninitialized(loggerContext);
loggerContext.getConfiguration().removeFilter(FILTER);
}
use of org.apache.logging.log4j.core.LoggerContext in project torodb by torodb.
the class Log4jUtils method reconfigure.
public static void reconfigure(String configurationFile) {
try {
LoggerContext coreContext = (LoggerContext) LogManager.getContext(false);
coreContext.setConfigLocation(new File(configurationFile).toURI());
} catch (Exception ex) {
throw new SystemException(ex);
}
}
use of org.apache.logging.log4j.core.LoggerContext in project torodb by torodb.
the class Log4jUtils method appendToLogFile.
public static void appendToLogFile(String logFile) {
LoggerContext coreContext = (LoggerContext) LogManager.getContext(false);
Configuration configuration = coreContext.getConfiguration();
final Layout<? extends Serializable> layout = PatternLayout.newBuilder().withConfiguration(configuration).withPattern("%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n").build();
final Appender appender = FileAppender.createAppender(logFile, "false", "false", "File", "true", "false", null, null, layout, null, "false", null, configuration);
appender.start();
for (LoggerConfig loggerConfig : configuration.getLoggers().values()) {
configuration.addLoggerAppender(coreContext.getLogger(loggerConfig.getName()), appender);
}
}
use of org.apache.logging.log4j.core.LoggerContext in project torodb by torodb.
the class Log4jUtils method setLogPackages.
public static void setLogPackages(Map<String, LogLevel> logPackages) {
for (Map.Entry<String, LogLevel> logPackage : logPackages.entrySet()) {
LoggerContext coreContext = (LoggerContext) LogManager.getContext(false);
Logger logger = coreContext.getLogger(logPackage.getKey());
setLevel(logger, logPackage.getValue());
}
}
use of org.apache.logging.log4j.core.LoggerContext in project graylog2-server by Graylog2.
the class LoggersResource method getLoggerLevel.
@VisibleForTesting
protected Level getLoggerLevel(final String loggerName) {
final LoggerContext loggerContext = (LoggerContext) LogManager.getContext(false);
final Configuration configuration = loggerContext.getConfiguration();
final LoggerConfig loggerConfig = configuration.getLoggerConfig(loggerName);
return loggerConfig.getLevel();
}
Aggregations