Skip to content

ZCU-DATA/Reduce warn logs noise - 404 dedicated logger#1275

Open
milanmajchrak wants to merge 1 commit intocustomer/zcu-datafrom
propagate/reduce-warn-logs-v2-zcu-data
Open

ZCU-DATA/Reduce warn logs noise - 404 dedicated logger#1275
milanmajchrak wants to merge 1 commit intocustomer/zcu-datafrom
propagate/reduce-warn-logs-v2-zcu-data

Conversation

@milanmajchrak
Copy link
Collaborator

Cherry-pick of commits 1dc5339 and db67645 into customer/zcu-data.

Problem description

  • Log 404 responses via dedicated Log4j2 logger (org.dspace.app.rest.exception.DSpaceApiExceptionControllerAdvice.NotFound) set to OFF by default
  • Extract getStatusCodesLoggedAsErrors() and logClientError() helper methods
  • Add sendErrorResponseFromException() for 4xx errors
  • Fix row length to be less than 120 chars

Original commits:

Copilot AI review requested due to automatic review settings March 13, 2026 14:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces REST API 404 warning log noise by routing NOT_FOUND client errors to a dedicated Log4j2 logger (OFF by default), while refactoring the REST exception advice to centralize client-error logging and configurable “log as ERROR” status-code handling.

Changes:

  • Add a dedicated Log4j2 logger for 404 NOT_FOUND responses (default OFF) in log4j2.xml.
  • Introduce a dedicated notFoundLog and extract helpers (logClientError(), getStatusCodesLoggedAsErrors()) in DSpaceApiExceptionControllerAdvice.
  • Add sendErrorResponseFromException() helper intended for 4xx responses.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
dspace/config/log4j2.xml Adds a dedicated (OFF-by-default) logger for 404 responses to suppress expected 404 noise.
dspace-server-webapp/src/main/java/org/dspace/app/rest/exception/DSpaceApiExceptionControllerAdvice.java Refactors client error logging and status-code error handling; adds a new helper method for 4xx error responses.

You can also share your feedback on Copilot code review. Take the survey.

} else {
StackTraceElement[] trace = ex.getStackTrace();
String location = trace.length <= 0 ? "unknown" : trace[0].toString();
logClientError(statusCode, message, ex.getClass().getName(), location);
@milanmajchrak milanmajchrak changed the title Reduce warn logs noise - 404 dedicated logger ZCU-DATA/Reduce warn logs noise - 404 dedicated logger Mar 13, 2026
@milanmajchrak milanmajchrak force-pushed the propagate/reduce-warn-logs-v2-zcu-data branch from 5cc6d5f to b9345b4 Compare March 13, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants