I don't want to whitelist every endpoint, I just want to ignore logging or change logging for specific endpoints.
This might be easily done with something like (edited 2018-02-14):
log access.log {
not /health
}
caddy -version)?v0.10.10
Skip logging for /health endpoints
http://*/ {
log stdout
errors stderr
bind 0.0.0.0
}
n/a
/health
/health log requests cannot be ignored. Log directive only supports base path matching.
Everything is logged, but I have an /health endpoint that I'd like to ignore
Run above caddyfile, and hit /health, try to modify Caddyfile to not log requests to /health
For the record, a more Caddy-omatic way to do this would be:
log access.log {
not /health
}
or
log access.log {
except /health
}
@mholt I figured out another way to accomplish this, but it's still not great:
http://*/health {
bind 0.0.0.0
}
http://*/ {
log stdout
errors stderr
bind 0.0.0.0
}
But this is pretty heavy for anything but this simple example.
I'll take a look at implementing this.
@mholt this seems an easy enough feature to add.
However I鈥檓 wondering does it warrant a little more discussion?
Is not writing entries in the log desirable? I may seems so in the short term but cause numerous issues in the long term. Perhaps a heartbeat url is not logged and the stops working? There is no indication in the logs anything has changed. If a ddos or other attack is attempted on a url that is not logged will this hamper investigation?
I know all of this is individual choice but I thought it was worth a little more discussion
I have an initial implementation it will have the following rules
log / log.txt {common} {
except /test
}
Will not log
Will log
Example2
log / log.txt {common} {
except /test/
}
Will not log
Will log
except value?test means test/ but what about except /test.pdf?My feeling is that there will need to be no special functionality eg test cannot mean test/. Allow Regex may make it easier to specify specific behaviour.
Thanks Toby, you did great work on this. Sorry I didn't get around to answering your questions.
Most helpful comment
For the record, a more Caddy-omatic way to do this would be:
or