mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-23 17:59:03 +00:00
Merge pull request #45967 from wonyongg
* pr/45967: Update copyright year of changed file Unify use of org.apache.logging.log4j.core.LoggerContext Closes gh-45967
This commit is contained in:
+6
-6
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2023 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,20 +54,20 @@ public class Log4J2MetricsAutoConfiguration {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user