New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Vapor 4] ErrorMiddleware should log the request path of a failed request #2199
Comments
I started on implementing this fix, but I'm realizing it might not make sense to port the Vapor 3 change directly to 4. In Vapor 4, we have With those two pieces of information, it's trivial to find the associated request method + path for a given error. Take the following example output from a test route I setup: app.get("error") { req -> String in
throw TestError()
}
Given including the request method + path again in the error log would be redundant in certain cases, I'm wondering if we should include it. All errors logged to |
Definitely like how this is going, one thing I would say is, is it possible to print the request ID in a fixed position for each request? Something like:
Might make it easier to work with in logging backends (though if the whole thing is wrapped in |
Interesting, @tanner0101 - that is definitely way better than the default behavior in Vapor 3. |
What about if we had it on a new line? Maybe indented as well:
The other thing to remember is that some pluggable logging backends will aggregate this metadata in a structured way and allow for filtering of results. (See https://github.com/apple/swift-log for backends currently supported). I haven't used these too much, but I imagine you can add a filter like |
When debugging requests that fail for some reason, it would be very helpful if
ErrorMiddleware
would print the path of the request. This was implemented in Vapor 3 a few days ago in #2170, and a similar approach would be enough to solve this in Vapor 4.The text was updated successfully, but these errors were encountered: