I’m proxying to a fairly high-traffic service (100s req/sec), and the systemd-journal process is using ~30% CPU (caddy2 uses ~10%, and the service itself around 8%). I have no need for the access logs, so I’d like to disable them completely.
The v2 docs mention logging in a few places, but its not clear if its possible to disable the access log from within a Caddyfile. It documents logging, but its not really clear how to disable the log, and there’s no examples of modifying the logs in the wikis.
My best guess is to use the admin UI to update the config:
That should probably solve your problem. (Logging is not yet configurable via the Caddyfile, that’s coming.)
Incidentally, your API request is close but not quite right. The path /config/logging traverses into the logging field:
{
"apps": {...},
"logging": {/* gets you into here */}
}
Thus, specifying {"logging": ...} as a field in your payload doesn’t make sense, because you already traversed into it. If your payload is just {"logs":{"access":{"writer":{"output":"discard"}}}} I suspect it will work?
Thanks @matt, upgrading to beta10 seems to have solved it. I was also tinkering with several config json formats trying to disable it, here’s what I’ve ended up that seems to work in beta10, if anyone else needs it:
To be clear, you shouldn’t need to put all logs to the discard if you just want to disable the HTTP access logs. They aren’t enabled by default, so you don’t need to alter your logging config like that:
Maybe I’m missing something. Wouldn’t putting it at “logging/logs/default” disable all logging? I assumed that having it at “logging/logs/access” would just disable the access logs.
Another possibility I tried was “logging/logs/http.log.access”, based on this part of the docs:
Access logs document HTTP requests as they come in; they use the namespace http.log.access
but that was in beta9, so I’m not sure which actually fixed it.
The answer is, don’t enable them. Enabling them is done in the definition of your HTTP servers: Home · caddyserver/caddy Wiki · GitHub (see the “logs” field).
All you have to do is not enable them, you don’t have to mess with the global logger configs at all.