Skip to content

Commit fbe7ddb

Browse files
committed
PropertySourcesPropertyResolver does not log retrieved value by default
Issue: SPR-14709
1 parent 55c37d2 commit fbe7ddb

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

spring-core/src/main/java/org/springframework/core/env/PropertySourcesPropertyResolver.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,19 @@ else if (value instanceof Class) {
137137
/**
138138
* Log the given key as found in the given {@link PropertySource}, resulting in
139139
* the given value.
140-
* <p>The default implementation writes a debug log message, including the value.
141-
* Subclasses may override this to change the log level and/or the log message.
140+
* <p>The default implementation writes a debug log message with key and source.
141+
* As of 4.3.3, this does not log the value anymore in order to avoid accidental
142+
* logging of sensitive settings. Subclasses may override this method to change
143+
* the log level and/or log message, including the property's value if desired.
142144
* @param key the key found
143145
* @param propertySource the {@code PropertySource} that the key has been found in
144146
* @param value the corresponding value
145147
* @since 4.3.1
146148
*/
147149
protected void logKeyFound(String key, PropertySource<?> propertySource, Object value) {
148150
if (logger.isDebugEnabled()) {
149-
logger.debug(String.format("Found key '%s' in [%s] with type [%s] and value '%s'",
150-
key, propertySource.getName(), value.getClass().getSimpleName(), value));
151+
logger.debug(String.format("Found key '%s' in [%s] with type [%s]",
152+
key, propertySource.getName(), value.getClass().getSimpleName()));
151153
}
152154
}
153155

0 commit comments

Comments
 (0)