No output for site log

1. Caddy version (caddy version):

2.46

2. How I run Caddy:

a. System environment:

Win10 v21H2 x64

b. Command:

caddy run

c. Service/unit/compose file:

d. My complete Caddyfile or JSON config:

{
	log caddy-log {
		output file caddy.log
		format console {
			time_format wall
		}
	}
	default_sni myserver.com
	debug
}
service.myserver.com:8443 {
	reverse_proxy :81
	log {
		output file web_access.log {
			roll true # Rotate logs, enabled by default
			roll_size_mb 10 # Set max size 10 MB
			roll_keep 2 # Keep at most 2 log files
		}
		level ERROR
	}
	header Strict-Transport-Security "max-age=63072000"
}

3. The problem I’m having:

web_access.log is never created. (Caddy.log is created.)

4. Error messages and/or full log output:

5. What I already tried:

6. Links to relevant resources:

Caddy probably just never had any ERROR level logs to write.

If you lower the log level to INFO, does the file get created?

I don’t get anything even if I remove the level param. I did try INFO and still nothing.

Are you sure you reloaded the config? How can we repro this?

I shutdown and restart Caddy between uses, so the config should be current. Not trying to be dunce, but to repro, set up a web server on port :81 and create a similar config. Is there something else you need from me to repro?

What kind of entries should I see in the site log that would be diff from the global log?

They would just be access logs, i.e. what each request looked like (URI, headers, etc.) and how Caddy responded (status, size, duration of the request).

Any more help available for this? Anyone else seeing this issue?

I tested this config on my Windows machine, it works fine, both log files are created and get contents written to:

{
	debug
	admin off

	log caddy-log {
		output file caddy.log
		format console {
			time_format wall
		}
	}
}

http://:8880 {
	log {
		output file web_access.log {
			roll true
			roll_size_mb 10
			roll_keep 2
		}
	}

	respond "foo" 200
}
1 Like

Interesting debug test. I also got a log with that. But what if you have another service behind 8880 besides Caddy’s server?

I just did that because I have another instance of Caddy running on the same machine bound to ports 80 and 443 (and admin on port 2019 so I turn off admin). The port being used is not relevant.

Righto. I was just following your test config. My point is the logging works with Caddy’s server, but what about a separate service like in my use case?

I don’t understand what you mean.

Your test config is using Caddy’s self-hosted server, right? Using that config produces a log file. But, if you use a separate server (e.g., Apache), do you still get a log file?

The known results thus far are:
self-hosted server → get log
separate server/service → don’t get a log

Just trying to confirm if that is the case for you, like it is for me.

I don’t see how that’s relevant. This is a forum about Caddy, and we’re talking about a Caddy config.

Yes, I know. Caddy is not producing a log in some cases. That is why I’m in the Caddy forum asking about it. If the Caddy config does not use the self-hosted server, it doesn’t produce a log.

Oh, you mean when reverse_proxy is being used.

No, that’s totally unrelated to logging. The reverse proxy module may emit logs, but that has nothing to do with the log writer.

Okay, so how do we solve the problem in question:

Am I missing something?

My answer is that I can’t replicate the problem, so I can’t really suggest anything specific.

Going back to your test config, which did not use a reverse proxy, it worked. So, what if you do use a reverse proxy, like I am, does it work for you?

Yes, it works with reverse_proxy as well. Deleted both log files, then just changed respond to reverse_proxy, started Caddy and I get both log files in the current working directory.