I’m using Caddy v0.11.5 and I’m noticing that the errors directive exhibits ambiguous behavior.
The docs clearly state that the errors directive will record errors (defined as HTTP status codes of 400 or greater) to the designated handler:
errors allows you to [...] and enable error logging. Without this middleware, error responses (HTTP 400+) are not logged and the client receives a plaintext error message. Using an error log, *the text of each error will be recorded so you can determine what is going wrong without exposing those details to the clients.*
However, the following configuration does not record HTTP 400+ errors:
errors /www/weblogs/errors.log {
rotate_age 30 # Days to keep
rotate_keep 7 # 7 files max
rotate_size 100 # Max size (MB)
rotate_compress
}
Strangely enough (and hence my claim of ambiguous behavior), the following configuration will:
errors /www/weblogs/errors.log {
# custom error handler (with invalid filename)
* filename_that_does_not_actually_exist.html
#
rotate_age 30 # Days to keep
rotate_keep 7 # 7 files max
rotate_size 100 # Max size (MB)
rotate_compress
}
Using the above misconfiguration, the errors.log will actually record three (3) error lines for each 404 error that transpires - one for the fact that the intended (by client) page was missing, one for the fact that the custom error page is missing, and one for the fact that a 404 took place.
Is there a way to simply have all 400+ HTTP status errors record in the errors file, without having to misconfigure the errors directive to do so? Yes, I can grep through the access log to find them, but I should be able to see them in the errors file as well, without all the associated noise. It doesn’t matter to me if they still continue to log in the access log, as long as I can log them separately as well. In some cases, I don’t have the access logs enabled - I only care about logging errors, so that they can be investigated.