Skip to content

Commit e337541

Browse files
committed
Merge branch 'main' into 4.0.x
2 parents 1255303 + 28c095c commit e337541

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/Log4J2MetricsAutoConfiguration.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,20 +54,20 @@ public Log4j2Metrics log4j2Metrics() {
5454

5555
static class Log4JCoreLoggerContextCondition extends SpringBootCondition {
5656

57+
private static final String LOGGER_CONTEXT_CLASS_NAME = "org.apache.logging.log4j.core.LoggerContext";
58+
5759
@Override
5860
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
5961
LoggerContext loggerContext = LogManager.getContext(false);
6062
try {
61-
if (Class.forName("org.apache.logging.log4j.core.LoggerContext").isInstance(loggerContext)) {
62-
return ConditionOutcome
63-
.match("LoggerContext was an instance of org.apache.logging.log4j.core.LoggerContext");
63+
if (Class.forName(LOGGER_CONTEXT_CLASS_NAME).isInstance(loggerContext)) {
64+
return ConditionOutcome.match("LoggerContext was an instance of " + LOGGER_CONTEXT_CLASS_NAME);
6465
}
6566
}
6667
catch (Throwable ex) {
6768
// Continue with no match
6869
}
69-
return ConditionOutcome
70-
.noMatch("Logger context was not an instance of org.apache.logging.log4j.core.LoggerContext");
70+
return ConditionOutcome.noMatch("LoggerContext was not an instance of " + LOGGER_CONTEXT_CLASS_NAME);
7171
}
7272

7373
}

0 commit comments

Comments
 (0)