Change DefaultSecurityFilterChain logging to DEBUG level and simplify filter log

- Change DefaultSecurityFilterChain logging level from INFO to DEBUG to align with FilterChainProxy.
- Log filter class names instead of the toString() of filter.
This commit is contained in:
baezzys 2024-05-19 18:43:53 +09:00 committed by Josh Cummings
parent da1869c271
commit ac9bdf5cbf

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2021 the original author or authors. * Copyright 2002-2024 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -32,6 +32,7 @@ import org.springframework.security.web.util.matcher.RequestMatcher;
* Standard implementation of {@code SecurityFilterChain}. * Standard implementation of {@code SecurityFilterChain}.
* *
* @author Luke Taylor * @author Luke Taylor
* @author Jinwoo Bae
* @since 3.1 * @since 3.1
*/ */
public final class DefaultSecurityFilterChain implements SecurityFilterChain { public final class DefaultSecurityFilterChain implements SecurityFilterChain {
@ -48,10 +49,21 @@ public final class DefaultSecurityFilterChain implements SecurityFilterChain {
public DefaultSecurityFilterChain(RequestMatcher requestMatcher, List<Filter> filters) { public DefaultSecurityFilterChain(RequestMatcher requestMatcher, List<Filter> filters) {
if (filters.isEmpty()) { if (filters.isEmpty()) {
logger.info(LogMessage.format("Will not secure %s", requestMatcher)); logger.debug(LogMessage.format("Will not secure %s", requestMatcher));
} }
else { else {
logger.info(LogMessage.format("Will secure %s with %s", requestMatcher, filters)); StringBuilder filterClassNames = new StringBuilder();
String separator = ", ";
for (Filter f : filters) {
if (!filterClassNames.isEmpty()) {
filterClassNames.append(separator);
}
filterClassNames.append(f.getClass().getSimpleName());
}
logger.debug(
LogMessage.format("Will secure %s with filters: %s", requestMatcher, filterClassNames.toString()));
} }
this.requestMatcher = requestMatcher; this.requestMatcher = requestMatcher;
this.filters = new ArrayList<>(filters); this.filters = new ArrayList<>(filters);