lhduc / laravel-gcp-logging
Reusable Google Cloud Logging integration for Laravel applications.
Requires
- php: ^8.2
- ext-json: *
- ext-mbstring: *
- google/cloud-logging: ^1.32
- guzzlehttp/guzzle: ^7.0
- laravel/framework: ^12
- monolog/monolog: ^3.0
Requires (Dev)
- orchestra/testbench: ^10.0
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-master
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- dev-fix/review-feedback-truncation-flush-level-http-errors
- dev-feat/redact-sensitive-data
- dev-fix/http-client-logging-keep-global-options
- dev-chore/tests-composer-excluded-routes-wildcard
- dev-fix/gcp-log-previous-exception-and-user-lookup
- dev-fix/limit-request-response-body-size
- dev-fix/gcp-log-compact-exception-and-cleanup
- dev-fix/gcp-log-throwable-and-batch-loss
- dev-fix/gcp-log-size-limit
This package is auto-updated.
Last update: 2026-10-27 13:48:12 UTC
README
Reusable package that wires a Google Cloud Logging channel into Laravel, adds correlation IDs, and captures HTTP client, queue, and request telemetry.
Installation
composer require lhduc/laravel-gcp-logging
Publish configuration
php artisan vendor:publish --provider="Lhduc\LaravelGcpLogging\Providers\GoogleLoggingServiceProvider" --tag=config
Configure config/google-logging.php or the matching environment variables (GOOGLE_PROJECT_ID, GOOGLE_APPLICATION_CREDENTIALS, GOOGLE_APPLICATION_NAME).
Enable channel
Update config/logging.php:
'channels' => [ // ... 'google' => [ 'driver' => 'custom', 'via' => Lhduc\LaravelGcpLogging\Logging\GoogleLogger::class, 'level' => env('LOG_LEVEL', 'debug'), 'project_id' => env('GOOGLE_APPLICATION_PROJECT'), 'key_file_path' => env('GOOGLE_APPLICATION_CREDENTIALS'), 'log_name' => env('GOOGLE_APPLICATION_NAME', 'application'), 'excluded_routes' => [ 'api/health-check', ], ], ],
excluded_routes entries match the route URI exactly and also accept * wildcards (e.g. api/health*).
Requests hitting the api middleware group automatically receive the correlation middleware. Queue jobs and outbound HTTP client calls will include the correlation identifier and emit structured entries in Google Cloud Logging.
Redaction
Sensitive values are replaced with [REDACTED] before an entry leaves the app: request/response headers and bodies, HTTP client calls, queue payloads, log context and URLs. The default redact_keys (see config/google-logging.php) cover authorization, cookie, password, token, otp, pin, secret, signature, api_key, private_key, credential, card_number, cvv, cvc.
- A key matches by word:
passwordalso masksuser_password,newPassword,passwords;pindoes not maskshipping. - JSON text, PHP-serialized text and
?token=...query strings inside string values are masked too (e.g. truncated bodies and queue payloads). - Add your own keys in
redact_keys; set it to[]to disable redaction.