1. Caddy version (caddy version
):
root@caddy:~ # caddy version
v2.4.0-beta.2 h1:DUaK4qtL3T0/gAm0fVVkHgcMN04r4zGpfPUZWHRR8QU=
2. How I run Caddy:
I use Caddyfile rather than JSON.
a. System environment:
TrueNAS 12.0-U3 (a FreeBSD derivative)
b. Command:
service caddy start
c. Service/unit/compose file:
n/a
d. My complete Caddyfile or JSON config:
This snippet is relevant:
(logging) {
log {
format json {
time_format iso8601
}
output file /var/log/caddy/{args.0}.log {
roll_size 100MiB # Default 100MiB
roll_keep 10 # Default 10
roll_keep_for 90d # Default 90d
}
}
}
A typical application of this snippet:
xenografix.com.au {
...
import logging xenografix.com.au
...
}
3. The problem I’m having:
Access logs become much more human-readable and useful because of the ISO8601 time format e.g.
{"level":"info","ts":"2021-05-02T12:37:27.793+0800","logger":"http.log.access.log0","msg":"handled request","request":{"remote_addr":"108.162.219.135:24096","proto":"HTTP/1.1","method":"HEAD","host":"xenografix.com.au","uri":"/","headers":{"X-Forwarded-For":["192.0.101.226"],"Cf-Ray":["648e8de8fa395523-EWR"],"X-Forwarded-Proto":["https"],"Cf-Visitor":["{\"scheme\":\"https\"}"],"Cf-Request-Id":["09ccf7059c0000552354286000000001"],"Connection":["Keep-Alive"],"Accept-Encoding":["gzip"],"Cf-Ipcountry":["US"],"User-Agent":["jetmon/1.0 (Jetpack Site Uptime Monitor by WordPress.com)"],"Cf-Connecting-Ip":["192.0.101.226"],"Cdn-Loop":["cloudflare"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"","proto_mutual":true,"server_name":"xenografix.com.au"}},"common_log":"108.162.219.135 - - [02/May/2021:12:37:27 +0800] \"HEAD / HTTP/1.1\" 200 0","duration":0.467530061,"size":0,"status":200,"resp_headers":{"Server":["Caddy","Caddy"],"Link":["<https://xenografix.com.au/wp-json/>; rel=\"https://api.w.org/\"","<https://xenografix.com.au/wp-json/wp/v2/pages/119>; rel=\"alternate\"; type=\"application/json\"","<https://xenografix.com.au/>;rel=shortlink"],"Vary":["Accept-Encoding, Cookie"],"X-Powered-By":["PHP/7.4.16"],"Date":["Sun, 02 May 2021 04:37:27 GMT"],"Content-Type":["text/html; charset=UTF-8"]}}
However, this is a site option and not a global option and seems to apply to access logs only.
Is it possible to have similar time stamping for console output as well? It appears though that this is more like a global option. I have noticed there is a format console
option, but again, this appears to be a site rather than a global option.
Here’s sample console log entry:
{"level":"info","ts":1619862602.6494813,"logger":"tls","msg":"cleaned up storage units"}
{"level":"info","ts":1619862602.6599119,"msg":"autosaved config (load with --resume flag)","file":"/.config/caddy/autosave.json"}
{"level":"info","ts":1619862602.6599343,"msg":"serving initial configuration"}
4. Error messages and/or full log output:
n/a
5. What I already tried:
Studied the various links in the next section.
6. Links to relevant resources:
- Global options
- log - Access logging
- Time_format examples please