1. The problem I’m having:
I want to have multiple access logs (one similar to Common Log Format and another one with JSON) for a site block, but only the last one defined in the Caddyfile is working (= log file is created and http requests appear in the log file). The other file (from the first occurrence of the log directivce) is not even created.
When I remove the 2nd log directive for the JSON output, then the remaining log directive for the plain (similar to Common Log Format) is working and the defined log file name is created and http requests are stored.
But I can’t get two access logs working at the same time.
2. Error messages and/or full log output:
No error messages.
3. Caddy version:
v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=
4. How I installed and ran Caddy:
Downloaded from Download Caddy with two extra features:
github.com/caddyserver/transform-encoder
github.com/ueffel/caddy-tls-format
a. System environment:
- Oracle Linux 8.8
Linux instance-20221129-1409 5.15.0-102.110.5.1.el8uek.aarch64 #2 SMP Sat Jun 10 18:23:55 PDT 2023 aarch64 aarch64 aarch64 GNU/Linux
b. Command:
./caddy start
curl -I http://localhost:18080/
ls -l access-localhost.*
# Only access-localhost.json exists, but I expect access-localhost.log as well
c. Service/unit/compose file:
not applicape
d. My complete Caddy config:
{
http_port 18080
debug
}
localhost:18080 {
log {
output file access-localhost.log
format filter {
wrap formatted "[{ts}] {request>remote_ip} {request>headers>X-Forwarded-For} {request>method} {request>host}{request>uri} {status} {request>headers>User-Agent>[0]} {request>headers>Referer} {http>auth>user>id} {request>tls>version} {request>tls>cipher_suite}" {
time_format "02.01.2006 15:04:05"
time_local
}
fields {
request>tls>version tls_version TLSv
request>tls>cipher_suite tls_cipher
}
}
}
log {
output file access-localhost.json
format filter {
wrap json
fields {
request>tls>version tls_version TLSv
request>tls>cipher_suite tls_cipher
}
}
}
respond "{http.request.uri}?{http.request.uri.query} {time.now.unix_ms}"
}