After adding the log section with the level PANIC parameter, the messages with the ERROR level from the specified sites, it seemed to me, disappeared. But there were messages with the INFO level from the general system of the Caddy server. For example, caddy | {“level”: “info”, “ts”: 1625784210.9643526, “logger”: “tls”, “msg”: “cleaned up storage units”}. How do I set the log level for general messages using the Caddyfile? Or perhaps in some other way?
4. Error messages and/or full log output:
5. What I already tried:
I have already read the documentation, sorry, but it seemed to me quite messy. I have searched on this forum. I was looking for examples of config files.
The log directive only configures per-site access logs.
The global option log configures logs for everything.
Log levels are the minimum level to output. PANIC is the highest level, which means you would only see PANIC level logs with that level (which are extremely rare, and should never actually get output). Access logs only actually emit INFO and ERROR logs.
It looks like my mistake. Apparently, support for configuring global logging in Caddyfile started with some recent version and my Docker container was not updated. After completely clearing the cached images, the Caddy server started.
For next time, please run caddy version to find out the exact version you’re using. You wrote:
Which is an inexact docker image tag.
Panics are in Go are basically fail-fast exit cases where something bad happened. Somewhat similar to exceptions in other programming languages; see Go by Example: Panic. In practice, they should never happen in Caddy, because it’s supposed to be a long-running server. It would be bad if Caddy exited unexpectedly, taking your site down with it. So panics in Caddy typically don’t result in exiting. You should ideally never see any of these, unless there’s a bug in Caddy or one of its dependencies.
Fatals are more abstract, essentially a case where the program decides it needed to exit directly without bubbling up to callers, via calling log.Fatal() which logs then exits in one operation. This should also never happen in Caddy, for the same reasons.
Caddy can fail to start though (exit before the server portion actually starts), if the config is invalid or there’s some other dependent problem (storage is not writable, etc). If Caddy if already running and you push a new config, then if that new config is invalid, then Caddy will simply not switch to that new config, and keep running with the old config.