Not logging PolicyViolation

My team is trying to cut down on extraneous error logging. We have some code that generates a TransportException from an error code. In one particular case, we want to return a 404, which results in a PolicyViolation. This has the same error code as a NotFound exception. But it seems that NotFound exceptions are not logged, whereas PolicyViolations are.

Is there a particular reason for this difference? Would it not make more sense to have the same logging behavior for both?

More generally, we’d like to get rid of error-level logs for client errors/any 400-level TransportException. Is there a particular way you’d recommend doing that?

Hmmm, never tried it but I’d first try to tune the logger so that only ERROR traces are logged (see here. The problem is what logger?

I checked on Lagom’s sources and noticed that maybeLogException is only invoked from ServiceRouter and the logger provided is named after the service that’s attending the call.

Unfortunately this part of the exception handling on the server side is not open to extension.

Thanks for the response. I should have specified that we’d ideally like to continue to log client errors, but at the INFO level rather than at the ERROR level. Tuning the logger as you describe would mean we wouldn’t see lower-level logs, but we’d still see the 4xx TransportExceptions because they’re logged as ERRORs. Do you have thoughts on how we could log those as INFO, instead?

Also, why are PolicyViolations logged while NotFound exceptions are not?

I’d also be open to adjusting the code to make the logging of exceptions in the ServiceRouters more customizable. Let me know if you have pointers regarding the best way to do this, e.g. the best place to pass in the logging configuration, the structure of such a config object, etc.

Ah, nice!

How about creating an issue in github and we can discuss the possible code changes there?