Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ public Log4j2Metrics log4j2Metrics() {

static class Log4JCoreLoggerContextCondition extends SpringBootCondition {

private static final String LOGGER_CONTEXT_CLASS_NAME = "org.apache.logging.log4j.core.LoggerContext";

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
LoggerContext loggerContext = LogManager.getContext(false);
try {
if (Class.forName("org.apache.logging.log4j.core.LoggerContext").isInstance(loggerContext)) {
return ConditionOutcome
.match("LoggerContext was an instance of org.apache.logging.log4j.core.LoggerContext");
if (Class.forName(LOGGER_CONTEXT_CLASS_NAME).isInstance(loggerContext)) {
return ConditionOutcome.match("LoggerContext was an instance of " + LOGGER_CONTEXT_CLASS_NAME);
}
}
catch (Throwable ex) {
// Continue with no match
}
return ConditionOutcome
.noMatch("Logger context was not an instance of org.apache.logging.log4j.core.LoggerContext");
return ConditionOutcome.noMatch("LoggerContext was not an instance of " + LOGGER_CONTEXT_CLASS_NAME);
}

}
Expand Down