Replace LoggingSystemProperties constants with an Enum
Extract contants from `LoggingSystemProperty` and `LogbackLoggingSystemProperties` in enum classes. Closes gh-36015pull/36032/head
parent
3a796aedea
commit
b6120d504a
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright 2012-2023 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.logging;
|
||||
|
||||
/**
|
||||
* Logging system properties that can later be used by log configuration files.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 3.2.0
|
||||
* @see LoggingSystemProperties
|
||||
*/
|
||||
public enum LoggingSystemProperty {
|
||||
|
||||
/**
|
||||
* Logging system property for the process ID.
|
||||
*/
|
||||
PID("PID"),
|
||||
|
||||
/**
|
||||
* Logging system property for the log file.
|
||||
*/
|
||||
LOG_FILE("LOG_FILE"),
|
||||
|
||||
/**
|
||||
* Logging system property for the log path.
|
||||
*/
|
||||
LOG_PATH("LOG_PATH"),
|
||||
|
||||
/**
|
||||
* Logging system property for the console log charset.
|
||||
*/
|
||||
CONSOLE_CHARSET("CONSOLE_LOG_CHARSET", "logging.charset.console"),
|
||||
|
||||
/**
|
||||
* Logging system property for the file log charset.
|
||||
*/
|
||||
FILE_CHARSET("FILE_LOG_CHARSET", "logging.charset.file"),
|
||||
|
||||
/**
|
||||
* Logging system property for the console log.
|
||||
*/
|
||||
CONSOLE_THRESHOLD("CONSOLE_LOG_THRESHOLD", "logging.threshold.console"),
|
||||
|
||||
/**
|
||||
* Logging system property for the file log.
|
||||
*/
|
||||
FILE_THRESHOLD("FILE_LOG_THRESHOLD", "logging.threshold.file"),
|
||||
|
||||
/**
|
||||
* Logging system property for the exception conversion word.
|
||||
*/
|
||||
EXCEPTION_CONVERSION_WORD("LOG_EXCEPTION_CONVERSION_WORD", "logging.exception-conversion-word"),
|
||||
|
||||
/**
|
||||
* Logging system property for the console log pattern.
|
||||
*/
|
||||
CONSOLE_PATTERN("CONSOLE_LOG_PATTERN", "logging.pattern.console"),
|
||||
|
||||
/**
|
||||
* Logging system property for the file log pattern.
|
||||
*/
|
||||
FILE_PATTERN("FILE_LOG_PATTERN", "logging.pattern.file"),
|
||||
|
||||
/**
|
||||
* Logging system property for the log level pattern.
|
||||
*/
|
||||
LEVEL_PATTERN("LOG_LEVEL_PATTERN", "logging.pattern.level"),
|
||||
|
||||
/**
|
||||
* Logging system property for the date-format pattern.
|
||||
*/
|
||||
DATEFORMAT_PATTERN("LOG_DATEFORMAT_PATTERN", "logging.pattern.dateformat");
|
||||
|
||||
private final String environmentVariableName;
|
||||
|
||||
private final String applicationPropertyName;
|
||||
|
||||
LoggingSystemProperty(String environmentVariableName) {
|
||||
this(environmentVariableName, null);
|
||||
}
|
||||
|
||||
LoggingSystemProperty(String environmentVariableName, String applicationPropertyName) {
|
||||
this.environmentVariableName = environmentVariableName;
|
||||
this.applicationPropertyName = applicationPropertyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of environment variable that can be used to access this property.
|
||||
* @return the environment variable name
|
||||
*/
|
||||
public String getEnvironmentVariableName() {
|
||||
return this.environmentVariableName;
|
||||
}
|
||||
|
||||
String getApplicationPropertyName() {
|
||||
return this.applicationPropertyName;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright 2012-2023 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.logging.logback;
|
||||
|
||||
/**
|
||||
* Logback rolling policy system properties that can later be used by log configuration
|
||||
* files.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @since 3.2.0
|
||||
* @see LogbackLoggingSystemProperties
|
||||
*/
|
||||
public enum RollingPolicySystemProperty {
|
||||
|
||||
/**
|
||||
* Logging system property for the rolled-over log file name pattern.
|
||||
*/
|
||||
FILE_NAME_PATTERN("file-name-pattern", "logging.pattern.rolling-file-name"),
|
||||
|
||||
/**
|
||||
* Logging system property for the clean history on start flag.
|
||||
*/
|
||||
CLEAN_HISTORY_ON_START("clean-history-on-start", "logging.file.clean-history-on-start"),
|
||||
|
||||
/**
|
||||
* Logging system property for the file log max size.
|
||||
*/
|
||||
MAX_FILE_SIZE("max-file-size", "logging.file.max-size"),
|
||||
|
||||
/**
|
||||
* Logging system property for the file total size cap.
|
||||
*/
|
||||
TOTAL_SIZE_CAP("total-size-cap", "logging.file.total-size-cap"),
|
||||
|
||||
/**
|
||||
* Logging system property for the file log max history.
|
||||
*/
|
||||
MAX_HISTORY("max-history", "logging.file.max-history");
|
||||
|
||||
private final String environmentVariableName;
|
||||
|
||||
private final String applicationPropertyName;
|
||||
|
||||
private final String deprecatedApplicationPropertyName;
|
||||
|
||||
RollingPolicySystemProperty(String applicationPropertyName, String deprecatedApplicationPropertyName) {
|
||||
this.environmentVariableName = "LOGBACK_ROLLINGPOLICY_" + name();
|
||||
this.applicationPropertyName = "logging.logback.rollingpolicy." + applicationPropertyName;
|
||||
this.deprecatedApplicationPropertyName = deprecatedApplicationPropertyName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of environment variable that can be used to access this property.
|
||||
* @return the environment variable name
|
||||
*/
|
||||
public String getEnvironmentVariableName() {
|
||||
return this.environmentVariableName;
|
||||
}
|
||||
|
||||
String getApplicationPropertyName() {
|
||||
return this.applicationPropertyName;
|
||||
}
|
||||
|
||||
String getDeprecatedApplicationPropertyName() {
|
||||
return this.deprecatedApplicationPropertyName;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue