Skip to content

Adjust DefaultSecurityFilterChain Logging Level and Simplify Filter Logging #15096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -32,6 +32,7 @@
* Standard implementation of {@code SecurityFilterChain}.
*
* @author Luke Taylor
* @author Jinwoo Bae
* @since 3.1
*/
public final class DefaultSecurityFilterChain implements SecurityFilterChain {
Expand All @@ -48,10 +49,21 @@ public DefaultSecurityFilterChain(RequestMatcher requestMatcher, Filter... filte

public DefaultSecurityFilterChain(RequestMatcher requestMatcher, List<Filter> filters) {
if (filters.isEmpty()) {
logger.info(LogMessage.format("Will not secure %s", requestMatcher));
logger.debug(LogMessage.format("Will not secure %s", requestMatcher));
}
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.filters = new ArrayList<>(filters);
Expand Down