Skip to content

Commit c9a3919

Browse files
committed
Add LoggingApplicationListener constants
Extract some of the common property keys as constants. Fixes gh-2068
1 parent f65c7db commit c9a3919

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,34 @@ public class LoggingApplicationListener implements SmartApplicationListener {
7373

7474
private static final Map<String, String> ENVIRONMENT_SYSTEM_PROPERTY_MAPPING;
7575

76+
/**
77+
* The name of the Spring property that contains a reference to the logging
78+
* configuration to load.
79+
*/
80+
public static final String CONFIG_PROPERTY = "logging.config";
81+
82+
/**
83+
* The name of the Spring property that contains the path where the logging
84+
* configuration can be found.
85+
*/
86+
public static final String PATH_PROPERTY = "logging.path";
87+
88+
/**
89+
* The name of the Spring property that contains the name of the logging configuration
90+
* file.
91+
*/
92+
public static final String FILE_PROPERTY = "logging.file";
93+
94+
/**
95+
* The name of the System property that contains the process ID.
96+
*/
7697
public static final String PID_KEY = "PID";
7798

7899
static {
79100
ENVIRONMENT_SYSTEM_PROPERTY_MAPPING = new HashMap<String, String>();
80-
ENVIRONMENT_SYSTEM_PROPERTY_MAPPING.put("logging.file", "LOG_FILE");
81-
ENVIRONMENT_SYSTEM_PROPERTY_MAPPING.put("logging.path", "LOG_PATH");
82-
ENVIRONMENT_SYSTEM_PROPERTY_MAPPING.put(PID_KEY, PID_KEY);
101+
ENVIRONMENT_SYSTEM_PROPERTY_MAPPING.put(FILE_PROPERTY, "LOG_FILE");
102+
ENVIRONMENT_SYSTEM_PROPERTY_MAPPING.put(PATH_PROPERTY, "LOG_PATH");
103+
ENVIRONMENT_SYSTEM_PROPERTY_MAPPING.put("PID", PID_KEY);
83104
}
84105

85106
private static MultiValueMap<LogLevel, String> LOG_LEVEL_LOGGERS;
@@ -194,8 +215,8 @@ private boolean mapSystemPropertiesFromSpring(Environment environment) {
194215

195216
private void initializeSystem(ConfigurableEnvironment environment,
196217
LoggingSystem system) {
197-
if (environment.containsProperty("logging.config")) {
198-
String value = environment.getProperty("logging.config");
218+
if (environment.containsProperty(CONFIG_PROPERTY)) {
219+
String value = environment.getProperty(CONFIG_PROPERTY);
199220
try {
200221
ResourceUtils.getURL(value).openStream().close();
201222
system.initialize(value);

0 commit comments

Comments
 (0)