mitbac
(Mit)
February 20, 2025, 1:03am
1
1. The problem I’m having:
When I try to configure the time format of logs, nothing happens. I don’t get an error message, the directives are simply not respected.
2. Error messages and/or full log output:
{"level":"info","ts":1740011348.4896889,"logger":"http.log.access.log0"
3. Caddy version:
v2.9.1
4. How I installed and ran Caddy:
a. System environment:
Windows Server 2025 Datacenter, version 10.0.2600 Build 26100
b. Command:
caddy run --config Caddyfile --environ --watch
c. Service/unit/compose file:
d. My complete Caddy config:
localhost:5000 {
reverse_proxy 172.28.105.105:5000
log {
output file .\logs\access.log {
roll_size 50MiB
format json {
time_format iso8601
time_local
duration_format ms
}
}
}
}
5. Links to relevant resources:
hmoffatt
(Hamish Moffatt)
February 20, 2025, 1:43am
2
Try forward slashes for the path? Try a full path instead of relative?
mitbac
(Mit)
February 20, 2025, 2:03am
3
Hm, the log file is generated fine. And it does log when it proxies requests properly, it’s the timestamp that is in the wrong format. This is on a Windows machine.
hmoffatt
(Hamish Moffatt)
February 20, 2025, 2:16am
4
Ah sorry I misread. I don’t see format ...
documented as an option on the output file ...
though, it should be a level up directly under log
.
log {
output file .\logs\access.log {
roll_size 50MiB
}
format json {
time_format iso8601
time_local
duration_format ms
}
}
mitbac
(Mit)
February 20, 2025, 3:03am
5
That fixed it! It was strange that the placement of format inside the output directive did not generate an error.
If you should want to proxy several paths, and want a separate logfile per path, would there be a way to set the format globally for all logs, so you don’t need to configure it inside every proxy directive?
hmoffatt
(Hamish Moffatt)
February 20, 2025, 3:34am
6
Not that I know of - perhaps use a snippet? That’s almost the exact example given. Caddyfile Concepts — Caddy Documentation
system
(system)
Closed
March 22, 2025, 3:35am
7
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.