Logging & debugging
When dealing with multiple endpoints, how to find out which endpoint handled a request, or why an endpoint didn’t handle a request?
For this purpose, tapir provides optional logging. The logging options (and messages) can be customised by providing
an instance of the
ServerLog trait, which is part of server options.
An instance of the default implementation,
DefaultServerLog, is available in the companion object for the
interpreter’s options class, e.g.
This instance can be customised using the following flags:
logWhenReceived: log when a request is first received (default:
logWhenHandled: log when a request is handled by an endpoint, or when the inputs can’t be decoded, and the decode failure maps to a response (default:
logAllDecodeFailures: log each time when the inputs can’t be decoded, and the decode failure doesn’t map to a response (the next endpoint will be tried; default:
logLogicExceptions: log when there’s an exception during evaluation of the server logic (default:
Logging all decode failures (3) might be helpful when debugging, but can also produce a large amount of logs, hence it’s disabled by default.
Additionally, you can customize the
.ignoreEndpoints to exclude some endpoints from logging with
logWhenHandled, but not from logging exceptions and decoding failures.
Even if logging for a particular category (as described above) is set to
true, normal logger rules apply - if you
don’t see the logs, please verify your logging levels for the appropriate packages.