Log directives not working

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:

Try forward slashes for the path? Try a full path instead of relative?

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.

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
		}
	}

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?

Not that I know of - perhaps use a snippet? That’s almost the exact example given. Caddyfile Concepts — Caddy Documentation

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.