diff --git a/CHANGELOG.md b/CHANGELOG.md index 396dabce8..d6dafa374 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased](https://github.com/laravel/octane/compare/v2.12.3...2.x) +### Added + +* FrankenPHP: Add env option `OCTANE_FRANKENPHP_DISABLE_ACCESS_LOGS` to disable Caddy access logs + ## [v2.12.3](https://github.com/laravel/octane/compare/v2.12.2...v2.12.3) - 2025-09-23 * Replace Octane::writeError with die statements by [@7amoood](https://github.com/7amoood) in https://github.com/laravel/octane/pull/1057 diff --git a/src/Commands/StartFrankenPhpCommand.php b/src/Commands/StartFrankenPhpCommand.php index 6f004b3f9..68e1f7ad3 100644 --- a/src/Commands/StartFrankenPhpCommand.php +++ b/src/Commands/StartFrankenPhpCommand.php @@ -84,6 +84,25 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve $serverName = $https ? "https://$host:$port" : "http://:$port"; + // Allow disabling Caddy access logs via environment variable (default: enabled) + $disableAccessLogs = env('OCTANE_FRANKENPHP_DISABLE_ACCESS_LOGS', false); + $logBlock = $disableAccessLogs + ? '# Access logs disabled via env' + : <<<'LOG' +log { + level {$CADDY_SERVER_LOG_LEVEL} + + # Redact the authorization query parameter that can be set by Mercure... + format filter { + wrap {$CADDY_SERVER_LOGGER} + fields { + uri query { + replace authorization REDACTED + } + } + } +} +LOG; $process = tap(new Process([ $frankenphpBinary, @@ -101,6 +120,7 @@ public function handle(ServerProcessInspector $inspector, ServerStateFile $serve 'CADDY_SERVER_ADMIN_HOST' => $this->option('admin-host'), 'CADDY_SERVER_LOG_LEVEL' => $this->option('log-level') ?: (app()->environment('local') ? 'INFO' : 'WARN'), 'CADDY_SERVER_LOGGER' => 'json', + 'CADDY_SERVER_LOG_BLOCK' => $logBlock, 'CADDY_SERVER_SERVER_NAME' => $serverName, 'CADDY_SERVER_WORKER_COUNT' => $this->workerCount() ?: '', 'CADDY_SERVER_WORKER_DIRECTIVE' => $this->workerCount() ? "num {$this->workerCount()}" : '', diff --git a/src/Commands/stubs/Caddyfile b/src/Commands/stubs/Caddyfile index 1cffcaa56..c7afb9cb2 100644 --- a/src/Commands/stubs/Caddyfile +++ b/src/Commands/stubs/Caddyfile @@ -15,19 +15,7 @@ {$CADDY_EXTRA_CONFIG} {$CADDY_SERVER_SERVER_NAME} { - log { - level {$CADDY_SERVER_LOG_LEVEL} - - # Redact the authorization query parameter that can be set by Mercure... - format filter { - wrap {$CADDY_SERVER_LOGGER} - fields { - uri query { - replace authorization REDACTED - } - } - } - } + {$CADDY_SERVER_LOG_BLOCK} route { root * "{$APP_PUBLIC_PATH}"