This change is aimed at enhancing the logging module within the Caddyfile directive to allow users to configure logs other than the HTTP access log stream, which is the current capability of the Caddyfile [1]. The intent here is to leverage the same syntax as the server log directive at a global level, so that similar customizations can be added without needing to resort to a JSON-based configuration. Discussion for this approach happened in the referenced issue. Closes https://github.com/caddyserver/caddy/issues/3958 [1] https://caddyserver.com/docs/caddyfile/directives/log
1.1 KiB
{ log { output file caddy.log include some-log-source exclude admin.api admin2.api } log custom-logger { output file caddy.log level WARN include custom-log-source } }
:8884 { log { format json output file access.log } }
{ "logging": { "logs": { "custom-logger": { "writer": { "filename": "caddy.log", "output": "file" }, "level": "WARN", "include": [ "custom-log-source" ] }, "default": { "writer": { "filename": "caddy.log", "output": "file" }, "include": [ "some-log-source" ], "exclude": [ "admin.api", "admin2.api", "custom-log-source", "http.log.access.log0" ] }, "log0": { "writer": { "filename": "access.log", "output": "file" }, "encoder": { "format": "json" }, "include": [ "http.log.access.log0" ] } } }, "apps": { "http": { "servers": { "srv0": { "listen": [ ":8884" ], "logs": { "default_logger_name": "log0" } } } } } }