- How do I install firevel/stackdriver-log-channel in a Laravel app?
- Install it with Composer by running composer require firevel/stackdriver-log-channel. Composer will resolve the package and its Google Cloud dependencies into your vendor directory. After that, register a channel in config/logging.php and point LOG_CHANNEL at it. Logging channels are configured through config/logging.php, so no application code changes are needed.
- How do I add the Stackdriver channel to config/logging.php?
- Add a new entry under the channels key in config/logging.php using the monolog driver and the Stackdriver handler class supplied by the package (check the README for the exact class name). Give the channel a name such as stackdriver and choose the minimum log level you want to send. Then set LOG_CHANNEL=stackdriver, or select it per call with Log::channel('stackdriver'). You can keep the default stack channel for local development.
- Does this package work with Google App Engine?
- Yes. The package is built for Laravel applications running on Google App Engine, where application logs are shipped to Google Cloud Stackdriver, now called Cloud Logging. On App Engine the platform's default credentials are used, so you do not need to embed a key file. You still configure it as a normal Laravel log channel in config/logging.php.
- How does authentication to Google Cloud work?
- The channel authenticates with Google Cloud using service-account credentials, typically a JSON key file referenced by an environment variable such as GOOGLE_APPLICATION_CREDENTIALS. On App Engine and other GCP runtimes the default service account is detected automatically. Make sure the account has permission to write log entries, for example the roles/logging.logWriter role. Do not commit key files to your repository.
- Which Laravel and PHP versions are supported?
- Version support is defined by the package's composer.json constraints for laravel/framework, monolog/monolog, and the Google Cloud logging library. Check those constraints on Packagist or in the repository before installing, especially if you are on an older Laravel release. Because Laravel's logging configuration and Monolog versions have changed across major releases, test the channel after framework upgrades.
- How are Laravel log levels mapped to Stackdriver severity?
- PSR-3 levels such as debug, info, notice, warning, error, critical, alert, and emergency are translated into the matching Cloud Logging severities, so entries appear with the right severity in the Logging console. Messages are sent as structured payloads with the message and context, which makes them filterable in Cloud Logging. The mapping itself is handled by the Monolog handler behind the channel.
- Can I use this channel outside Google App Engine?
- Yes, provided the machine can reach the Cloud Logging API and has valid credentials. The channel writes through Google's client library, so it is not strictly tied to App Engine. On a VPS or another cloud you would supply a service-account key via GOOGLE_APPLICATION_CREDENTIALS.
- How do I test logs locally without sending them to GCP?
- Do not send test traffic to Cloud Logging. In phpunit.xml or your local .env, set LOG_CHANNEL to a local channel such as single or stderr, and keep the stackdriver channel for deployed environments only. If you need to assert that entries were emitted, mock or swap the Monolog handler rather than calling GCP. This keeps tests fast and avoids credential requirements in CI.
- Do I need to change my application code to use it?
- No. You keep using Laravel's Log facade, the logger() helper, or Log::channel() as usual; the only change is selecting the Stackdriver channel. The package plugs in as a Monolog handler, so existing log calls and context arrays continue to work. There is nothing to add to controllers or services.
- Is the package actively maintained, and what are the alternatives?
- Check the repository's releases, open issues, and commit history to judge current maintenance before adopting it, since logging integrations depend on the Google Cloud logging library and Monolog versions. Alternatives include writing a small custom Monolog handler around the Google Cloud Logging client, using another community Stackdriver handler, or on App Engine simply writing structured JSON to stdout and letting the platform ingest it. The stdout approach is often the lowest-maintenance option on App Engine.