Merge pull request #3644 from eugenp/BAEL-1501

Bael 1501
This commit is contained in:
Loredana Crusoveanu 2018-03-18 14:54:19 +02:00 committed by GitHub
commit 8a4dbf244d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View File

@ -32,19 +32,22 @@ public class ClientErrorLoggingFilter extends GenericFilterBean {
Authentication auth = SecurityContextHolder.getContext()
.getAuthentication();
if (auth != null) {
int status = ((HttpServletResponse) response).getStatus();
if (status >= 400 && status < 500) {
if (errorCodes == null) {
logger.debug("User " + auth.getName() + " encountered error " + status);
} else {
if (errorCodes.stream()
.filter(s -> s.value() == status)
.findFirst()
.isPresent()) {
logger.debug("User " + auth.getName() + " encountered error " + status);
}
}
if (auth == null) {
chain.doFilter(request, response);
return;
}
int status = ((HttpServletResponse) response).getStatus();
if (status < 400 || status >= 500) {
chain.doFilter(request, response);
return;
}
if (errorCodes == null) {
logger.debug("User " + auth.getName() + " encountered error " + status);
} else {
if (errorCodes.stream()
.anyMatch(s -> s.value() == status)) {
logger.debug("User " + auth.getName() + " encountered error " + status);
}
}

View File

@ -2,4 +2,4 @@ server.port=8081
logging.level.root=INFO
logging.level.com.baeldung.dsl.ClientErrorLoggingFilter=DEBUG
logging.level.com.baeldung.dsl.ClientErrorLoggingFilter=DEBUG