PHPackages                             beyounglabs/monolog-stackdriver - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. beyounglabs/monolog-stackdriver

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

beyounglabs/monolog-stackdriver
===============================

Stackdriver handler for Monolog (codeinternetapplications/monolog-stackdriver Fork).

2.0.1(4y ago)02.2kMITPHPPHP &gt;=8.0

Since Feb 18Pushed 4y agoCompare

[ Source](https://github.com/beyounglabs/monolog-stackdriver)[ Packagist](https://packagist.org/packages/beyounglabs/monolog-stackdriver)[ Docs](http://github.com/beyounglabs/monolog-stackdriver)[ RSS](/packages/beyounglabs-monolog-stackdriver/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (1)Dependencies (2)Versions (9)Used By (0)

MonologStackdriver
==================

[](#monologstackdriver)

This package enables you to push your [Monolog](https://packagist.org/packages/monolog/monolog) log entries to [Stackdriver](https://cloud.google.com/stackdriver) which is part of the [Google Cloud Platform](https://cloud.google.com).

The supplied `StackdriverHandler` copies the given log level into the Stackdriver's severity based on your log method.

It also respects the context argument which allows you to send extra contextual data with your log message. This will be stored in the log message under `jsonPayload.data`.

---

Configuration
=============

[](#configuration)

Service account
---------------

[](#service-account)

With our samples we assume you have a service account Google Developers Console JSON key file available within your project to point at with read rights.

If you don't have this file yet, you can create it via [Google Cloud Platform - IAM &amp; Admin - Service accounts](https://console.cloud.google.com/iam-admin/serviceaccounts). Please make sure you have at least the role of `Logs writer` enabled.

Google\\Cloud\\Logging\\LoggingClient options
---------------------------------------------

[](#googlecloudloggingloggingclient-options)

Please read the documentation for the [Google\\Cloud\\Logging\\LoggingClient](https://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.61.0/logging/loggingclient?method=__construct) for other authentication options and further specific connection and setup.

Google\\Cloud\\Logging\\Logger options
--------------------------------------

[](#googlecloudlogginglogger-options)

Please read the documentation for the [Google\\Cloud\\Logging\\Logger setup via Google\\Cloud\\Logging\\LoggingClient](https://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.61.0/logging/loggingclient?method=logger) for specific details about these options.

This set of options will allow you to set the default resource type and it's related labels that apply to all the logs. Please read [Method: monitoredResourceDescriptors.list](https://cloud.google.com/logging/docs/reference/v2/rest/v2/monitoredResourceDescriptors/list) and do the "Try this API" to get a full list of the specific labels per resource.

Google\\Cloud\\Logging\\Entry options
-------------------------------------

[](#googlecloudloggingentry-options)

Please read the documentation for the [Google\\Cloud\\Logging\\Entry setup via Google\\Cloud\\Logging\\Logger](http://googlecloudplatform.github.io/google-cloud-php/#/docs/google-cloud/v0.61.0/logging/logger?method=entry) for specific details about these options.

By default, you can add Stackdriver specific log entry options by adding these wrapped in the `stackdriver`-key inside the context array. Very useful to add log entry specific labels for instance.

```
$context['stackdriver'] = [
    // stackdriver related entry options
];
```

If you need to, you can override this key name by setting `$entryOptionsWrapper` to your own value (string) when using `StackdriverHandler::__construct`.

It is also possible to set path to credentials and project id via the global constant.

```
define('GOOGLE_APPLICATION_CREDENTIALS', '/path/to/service-account-key-file.json');
define('GOOGLE_CLOUD_PROJECT', 'eg-my-project-id-148223');
```

Pick your framework for some specific setup
-------------------------------------------

[](#pick-your-framework-for-some-specific-setup)

- [Laravel/Laravel v5.5](docs/laravel_laravel_v5_5.md)
- [Laravel/Laravel v5.6](docs/laravel_laravel_v5_6.md)
- [Laravel/Laravel v5.7](docs/laravel_laravel_v5_7.md)
- [Laravel/Lumen v5.5](docs/laravel_lumen_v5_5.md)
- [Laravel/Lumen v5.6](docs/laravel_lumen_v5_6.md)
- [Laravel/Lumen v5.7](docs/laravel_lumen_v5_7.md)

Vanilla usage
=============

[](#vanilla-usage)

```
use Monolog\Logger;
use CodeInternetApplications\MonologStackdriver\StackdriverHandler;

// ( ... )

// GCP Project ID
$projectId = 'eg-my-project-id-148223';

// See Google\Cloud\Logging\LoggingClient::__construct
$loggingClientOptions = [
    'keyFilePath' => '/path/to/service-account-key-file.json'
];

// init handler
$stackdriverHandler = new StackdriverHandler(
    $projectId,
    $loggingClientOptions
);

// init logger with StackdriverHandler
$logger = new Logger('stackdriver', [$stackdriverHandler]);

// basic info log with contextual data
$logger->info('New order', ['orderId' => 1001]);
```

```
// ( ... )

// add specific log entry options, eg labels
$context = ['orderId' => 1001];

// add a 'stackdriver' entry to the context to append
// log entry specific options
$context['stackdriver'] = [
    'labels' => [
        'action' => 'paid'
    ]
];
$logger->info('Order update', $context);
```

```
// ( ... )

// add specific log entry options, eg labels and operation
$context = ['orderId' => 1001];
$context['stackdriver'] = [
    'labels' => [
        'order' => 'draft'
    ],
    'operation' => [
        'id' => 'order-1001',
        'first' => true,
        'last' => false
    ]
];
$logger->info('Order update', $context);

// update both label and operation
$context['stackdriver'] = [
    'labels' => [
        'order' => 'paid'
    ],
    'operation' => [
        'id' => 'order-1001',
        'first' => false,
        'last' => false
    ]
];
$logger->info('Order update', $context);

// update both label and operation again
$context['stackdriver'] = [
    'labels' => [
        'order' => 'fulfilled'
    ],
    'operation' => [
        'id' => 'order-1001',
        'first' => false,
        'last' => true
    ]
];
$logger->info('Order update', $context);
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity73

Established project with proven stability

 Bus Factor1

Top contributor holds 61.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~237 days

Recently: every ~344 days

Total

7

Last Release

1579d ago

Major Versions

1.2.1 → 2.0.02019-11-28

PHP version history (3 changes)1.0.0PHP &gt;=7.0.0

2.0.0PHP ^7.2

2.0.1PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ed729a4ae2cc2f39cb917240265ef39758a80c62e2ebf717af89e73e5d0ce933?d=identicon)[pierophp](/maintainers/pierophp)

---

Top Contributors

[![martinatcode](https://avatars.githubusercontent.com/u/19168549?v=4)](https://github.com/martinatcode "martinatcode (11 commits)")[![codeinternetapplications](https://avatars.githubusercontent.com/u/25244874?v=4)](https://github.com/codeinternetapplications "codeinternetapplications (3 commits)")[![ivanbooxi](https://avatars.githubusercontent.com/u/36636565?v=4)](https://github.com/ivanbooxi "ivanbooxi (2 commits)")[![pierophp](https://avatars.githubusercontent.com/u/125132?v=4)](https://github.com/pierophp "pierophp (2 commits)")

---

Tags

loglaravellogginglumenmonologgoogle cloudgcpstackdriver

### Embed Badge

![Health badge](/badges/beyounglabs-monolog-stackdriver/health.svg)

```
[![Health](https://phpackages.com/badges/beyounglabs-monolog-stackdriver/health.svg)](https://phpackages.com/packages/beyounglabs-monolog-stackdriver)
```

###  Alternatives

[codeinternetapplications/monolog-stackdriver

Stackdriver handler for Monolog.

14181.7k](/packages/codeinternetapplications-monolog-stackdriver)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[thecoder/laravel-monolog-telegram

Telegram Handler for Monolog

2939.5k](/packages/thecoder-laravel-monolog-telegram)[melihovv/laravel-log-viewer

A Laravel log viewer

1231.5k1](/packages/melihovv-laravel-log-viewer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
