DefaultErrorHandler Logging Level for Alert Discrimination
0 reputation · 12 May 2022, 16:29 UTC
Ktor's DefaultErrorHandler provides a centralized mechanism for customizing error responses, yet its logging behavior across development and production environments often results in notification noise when unhandled exceptions propagate to monitoring systems. A precise goal is to configure the handler so that only errors meeting a defined severity threshold generate alerts, while routine exceptions are logged at a diagnostic level without stack trace exposure.
The constraint involves distinguishing between application-internal errors and externally visible failures within the same handler lambda, particularly given the API divergence between Ktor 2.x and 3.x where onCallException and onDeploymentException callbacks offer finer control but require version‑aware implementation.
How should the logging level be parameterized to surface critical errors to observability platforms without flooding logs? Can a single DefaultErrorHandler configuration reliably map exception types to both custom JSON response bodies and differentiated log severity? What criteria should govern the transition from silent logging to alert‑triggering error paths?