caddyserver/caddy · error

setting up sink log: %v

Error message

setting up sink log: %v

What it means

During Logging.Provision, the 'sink' logger (which captures the Go standard library's global logger) is provisioned first. This error wraps any failure from that setup, e.g. its writer module failing to load or open.

Source

Thrown at logging.go:99

}

// openLogs sets up the config and opens all the configured writers.
// It closes its logs when ctx is canceled, so it should clean up
// after itself.
func (logging *Logging) openLogs(ctx Context) error {
	// make sure to deallocate resources when context is done
	ctx.OnCancel(func() {
		err := logging.closeLogs()
		if err != nil {
			Log().Error("closing logs", zap.Error(err))
		}
	})

	// set up the "sink" log first (std lib's default global logger)
	if logging.Sink != nil {
		err := logging.Sink.provision(ctx, logging)
		if err != nil {
			return fmt.Errorf("setting up sink log: %v", err)
		}
	}

	// as a special case, set up the default structured Caddy log next
	if err := logging.setupNewDefault(ctx); err != nil {
		return err
	}

	// then set up any other custom logs
	for name, l := range logging.Logs {
		// the default log is already set up
		if name == DefaultLoggerName {
			continue
		}

		err := l.provision(ctx, logging)
		if err != nil {
			return fmt.Errorf("setting up custom log '%s': %v", name, err)

View on GitHub (pinned to 50e54ee279)

Solutions

  1. Check the wrapped error for the real cause (module load vs writer open).
  2. Fix or remove the sink writer config; omitting it uses stderr defaults.
  3. Ensure writer modules (e.g. file with rolling) have valid options and writable paths.
  4. If using a custom-compiled Caddy, confirm the writer module is included in the build.

Example fix

// before
"logging": { "sink": { "writer": { "output": "fil" } } }
// after
"logging": { "sink": { "writer": { "output": "file", "filename": "/var/log/caddy-sink.log" } } }
Defensive patterns

Strategy: validation

Try / catch

if err := cfg.Provision(ctx); err != nil {
    if strings.Contains(err.Error(), "setting up sink log") {
        // fix/remove logging.sink writer config, re-provision
    }
}

Prevention

When it happens

Trigger: Config with logging.sink containing an invalid writer (bad module name, unreadable file path, bad log rolling options for file writers). The failure happens at config provision time, before any other logs start.

Common situations: JSON configs defining "sink": { "writer": {...} } with a typo'd writer type or a directory the Caddy user cannot write to; adapting examples that reference enterprise-only writer modules not compiled into the build.

Related errors


AI-assisted analysis of caddyserver/caddy@50e54ee279 (2026-08-15). Data as JSON: /api/errors/644875a0acf2c559. Report an issue: GitHub.