Logging Configuration
Caddy provides zero-allocation, high-performance structured logging using Zap. Logs can be customized with different outputs, encoders, and filters.Default Logging
By default, Caddy logs to stderr at INFO level:Log Configuration
Custom Log Output
Log Levels
Available log levels (from most to least verbose):- DEBUG - Detailed debugging information
- INFO - General informational messages (default)
- WARN - Warning messages
- ERROR - Error messages
- PANIC - Panic messages (causes panic)
- FATAL - Fatal messages (causes exit)
Log Encoders
JSON Encoder
Structured JSON output:Console Encoder
Human-readable output:Custom Format
Log Writers
File Writer
Network Writer
Send logs over the network:Standard Streams
Discard
Disable logging:Log Filtering
Include Specific Modules
Only log from specific modules:Exclude Modules
Filter out specific modules:Complex Filtering
Combine include and exclude:When both include and exclude are set, longer namespaces have priority. The lists must be mutually exclusive superset/subset pairs.
HTTP Access Logs
Configure access logs per site:Access Log Fields
Customize which fields to log:Sampling
Reduce log volume on high-traffic servers:Caller Information
Include file and line numbers in logs:Multiple Logs
Configure different logs for different purposes:Sink Log
Configure the sink for stdlib logger output:The sink captures logs from Go’s standard library logger, used by dependencies not built specifically for Caddy.
Complete Example
Log Module Names
Common logger names for filtering:http- All HTTP-related logshttp.log.access- HTTP access logshttp.handlers.*- HTTP handler logshttp.handlers.reverse_proxy- Reverse proxy logshttp.handlers.file_server- File server logsadmin- Admin endpoint logsadmin.api- Admin API logstls- TLS/certificate logstls.issuance- Certificate issuance logs