Skip to content

Commit 64eb36b

Browse files
rgoersphilwebb
authored andcommitted
Support 'log4j.configurationFile' system property
Update `Log4J2LoggingSystem.getStandardConfigLocations()` so that any configured 'log4j.configurationFile' system property is also included as a location. See gh-32730
1 parent ec17b78 commit 64eb36b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

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

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.LinkedHashMap;
2525
import java.util.List;
2626
import java.util.Map;
27+
import java.util.Properties;
2728
import java.util.Set;
2829
import java.util.logging.ConsoleHandler;
2930
import java.util.logging.Handler;
@@ -45,6 +46,7 @@
4546
import org.apache.logging.log4j.core.util.NameUtil;
4647
import org.apache.logging.log4j.jul.Log4jBridgeHandler;
4748
import org.apache.logging.log4j.message.Message;
49+
import org.apache.logging.log4j.util.PropertiesUtil;
4850

4951
import org.springframework.boot.context.properties.bind.BindResult;
5052
import org.springframework.boot.context.properties.bind.Bindable;
@@ -137,6 +139,11 @@ private String[] getCurrentlySupportedConfigLocations() {
137139
Collections.addAll(supportedConfigLocations, "log4j2.json", "log4j2.jsn");
138140
}
139141
supportedConfigLocations.add("log4j2.xml");
142+
PropertiesUtil props = new PropertiesUtil(new Properties());
143+
String location = props.getStringProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY);
144+
if (location != null) {
145+
supportedConfigLocations.add(location);
146+
}
140147
return StringUtils.toStringArray(supportedConfigLocations);
141148
}
142149

0 commit comments

Comments
 (0)