Skip to content

Commit 16b17d8

Browse files
committed
Refactor Log4j2 to use Template Method for system properties
Signed-off-by: hojooo <[email protected]>
1 parent 05f8bb4 commit 16b17d8

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

core/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/Log4J2LoggingSystem.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@
6565
import org.springframework.boot.logging.LoggingInitializationContext;
6666
import org.springframework.boot.logging.LoggingSystem;
6767
import org.springframework.boot.logging.LoggingSystemFactory;
68+
import org.springframework.boot.logging.LoggingSystemProperties;
6869
import org.springframework.core.Conventions;
6970
import org.springframework.core.annotation.Order;
71+
import org.springframework.core.env.ConfigurableEnvironment;
7072
import org.springframework.core.env.Environment;
7173
import org.springframework.core.io.Resource;
7274
import org.springframework.core.io.ResourceLoader;
@@ -155,6 +157,11 @@ public Log4J2LoggingSystem(ClassLoader classLoader) {
155157
super(classLoader);
156158
}
157159

160+
@Override
161+
public LoggingSystemProperties getSystemProperties(ConfigurableEnvironment environment) {
162+
return new Log4j2LoggingSystemProperties(environment, getDefaultValueResolver(environment), null);
163+
}
164+
158165
@Override
159166
protected String[] getStandardConfigLocations() {
160167
List<String> locations = new ArrayList<>();
@@ -324,15 +331,10 @@ private void load(LoggingInitializationContext initializationContext, String loc
324331
List<String> overrides = getOverrides(initializationContext);
325332
Environment environment = initializationContext.getEnvironment();
326333
Assert.state(environment != null, "'environment' must not be null");
327-
applyLog4j2SystemProperties(environment, logFile);
334+
applySystemProperties(environment, logFile);
328335
loadConfiguration(location, logFile, overrides);
329336
}
330337

331-
332-
private void applyLog4j2SystemProperties(Environment environment, @Nullable LogFile logFile) {
333-
new Log4j2LoggingSystemProperties(environment, getDefaultValueResolver(environment), null).apply(logFile);
334-
}
335-
336338
private List<String> getOverrides(LoggingInitializationContext initializationContext) {
337339
Environment environment = initializationContext.getEnvironment();
338340
Assert.state(environment != null, "'environment' must not be null");

0 commit comments

Comments
 (0)