How to log to stdout and stderr

1. The problem I’m having:

I’d like to log caddy errors to stderr and caddy output to stdout, and not both to just stderr OR stdout.

3. Caddy version:


4. How I installed and ran Caddy:

a. System environment:


d. My complete Caddy config:

	#tls {$TLS_EMAIL} {
	#	ca
	#	eab {$EAB_KID} {$EAB_HMAC}

	# Test HTTPS setup
	#tls {$TLS_EMAIL} {
	#	ca

	# Serves static files
	root * /var/www

	# Serves dynamic requests
	@notStatic {
		not path /static/*
	reverse_proxy @notStatic django:8000

	encode zstd gzip

	log {
		output stdout

The log directive inside a site block only configures access logs (i.e. simple request logging).

To configure the rest of the logs, you need to use the log global option (in the global options block), in which case you can make two loggers with different log levels. I don’t think it’s possible to set a maximum log level though, only a minimum (which defaults to INFO). Maybe we should add that at some point.

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