1. Output of caddy version
:
v2.6.0 h1:lHDynvM+sTOi9Aq4Y15b4FtkqzPB36WbUrZvVdwzTCA=
2. How I run Caddy:
running directly in vm, no docker
a. System environment:
Amazon Linux 2
b. Command:
caddy adapt Caddyfile
c. Service/unit/compose file:
d. My complete Caddy config:
localhost {
encode zstd gzip
templates
file_server browse
log {
output file /var/log/access.log {
roll_size 1gb
roll_keep 5
roll_keep_for 720h
}
}
}
Trying to configure a server to log using the json configuration instead of caddyfile however the documentation for json configuration is not very helpful so I tried adapting a stock caddyfile to json and the resultant output isn’t well documented (see json output below).
The first thing that’s non obvious is why is there a “default” logs which excludes “http.log.access.log0”. Why and what does that do? Not seeing any documentation for that here JSON Config Structure - Caddy Documentation it simply references “http.log.access”
"default": {
"exclude": [
"http.log.access.log0"
]
},
The log0 setting goes and includes “http.log.access.log0”? Why is that? There is no documentation at JSON Config Structure - Caddy Documentation which would identify what the other possible options are beyond: “admin.api”
"log0": {
"writer": {
"filename": "/var/log/access.log",
"output": "file",
"roll_keep": 5,
"roll_keep_days": 30,
"roll_size_mb": 954
},
"include": [
"http.log.access.log0"
]
}
Within the “apps” “http” directive there’s a “logs” which references a “logger_names” of “localhost”: “log0”. Is “localhost” always supposed to be the name of the host?
"logs": {
"logger_names": {
"localhost": "log0"
}
}
This doesn’t seem to track because if you use a caddyfile where you replace localhost with :443 you get an entirely different “logs” section
"logs": {
"default_logger_name": "log0"
}
4. Error messages and/or full log output:
{
"logging": {
"logs": {
"default": {
"exclude": [
"http.log.access.log0"
]
},
"log0": {
"writer": {
"filename": "/var/log/access.log",
"output": "file",
"roll_keep": 5,
"roll_keep_days": 30,
"roll_size_mb": 954
},
"include": [
"http.log.access.log0"
]
}
}
},
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":443"
],
"routes": [
{
"match": [
{
"host": [
"localhost"
]
}
],
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"encodings": {
"gzip": {},
"zstd": {}
},
"handler": "encode",
"prefer": [
"zstd",
"gzip"
]
},
{
"handler": "templates"
},
{
"browse": {},
"handler": "file_server",
"hide": [
"./Caddyfile"
]
}
]
}
]
}
],
"terminal": true
}
"logs": {
"logger_names": {
"localhost": "log0"
}
}
}
}
}
}
}