Logging http response states

Hey,

In the case or our project we need to log (i.e.) if there is a 401 response thrown back at the user.
Currently we can see this in our New Relic, but only because there is a 401.jsp being rendered.

In addition to that, we have configured, that our logs are sent to splunk.
Now those 401 errors should also be logged and be sent to splunk.

Is there an elegant solution for logging such cases? Is there any class that can be traced in the log4j config that is responsible for these response codes?

Thanks in advance!

Maybe this can give you some inspiration: