PHPackages                             stackify/monolog - 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. stackify/monolog

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

stackify/monolog
================

Stackify logs and errors for Monolog

3.1.0(1y ago)3269.1k↓33.7%6Apache-2.0PHPPHP &gt;=8.1

Since Dec 29Pushed 6mo ago13 watchersCompare

[ Source](https://github.com/stackify/stackify-log-monolog)[ Packagist](https://packagist.org/packages/stackify/monolog)[ Docs](https://github.com/stackify/stackify-log-monolog)[ RSS](/packages/stackify-monolog/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (20)Used By (0)

Stackify Monolog v3 Handler
===========================

[](#stackify-monolog-v3-handler)

Monolog handler for sending log messages and exceptions to Stackify. Monolog &gt;= 3.0.0 is supported.

For Monolog V1

> Use the [1.x branch](https://github.com/stackify/stackify-log-monolog/tree/1.x)

For Monolog V2

> Use the [2.x branch](https://github.com/stackify/stackify-log-monolog/tree/2.x)

- **Errors and Logs Overview:**
- **Sign Up for a Trial:**

Installation
------------

[](#installation)

Install the latest version with `composer require stackify/monolog "~2.0"`

### Installation with Linux Agent

[](#installation-with-linux-agent)

This is the suggested installation option, offering the best logging performance.

**PHP:**

```
use Monolog\Logger;
use Stackify\Log\Monolog\Handler as StackifyHandler;

$handler = new StackifyHandler('application_name', 'environment_name');
$logger = new Logger('logger');
$logger->pushHandler($handler);
```

**Symfony:**

```
services:
    stackify_handler:
        class: "Stackify\\Log\\Monolog\\Handler"
        arguments: ["application_name", "environment_name"]
monolog:
    handlers:
        stackify:
            type: service
            id: stackify_handler
```

#### Optional Settings

[](#optional-settings)

**Log Server Environment Variables**

- Server environment variables can be added to error log message metadata. **Note:** This will log all system environment variables; do not enable if sensitive information such as passwords or keys are stored this way.

```
$handler = new StackifyHandler('application_name', 'environment_name', null, true);
```

### Installation without Linux Agent

[](#installation-without-linux-agent)

This option does not require a Stackify Agent to be installed because it sends data directly to Stackify services. It collects log entries in batches, calls curl using the `exec` function, and sends data to the background immediately \[`exec('curl ... &')`\]. This will affect the performance of your application minimally, but it requires permissions to call `exec` inside the PHP script and it may cause silent data loss in the event of any network issues. This transport method does not work on Windows. To configure ExecTransport you need to pass the environment name and API key (license key):

**PHP:**

```
use Stackify\Log\Transport\ExecTransport;
use Stackify\Log\Monolog\Handler as StackifyHandler;

$transport = new ExecTransport('api_key');
$handler = new StackifyHandler('application_name', 'environment_name', $transport);
$logger = new Logger('logger');
$logger->pushHandler($handler);
```

**Symfony:**

```
services:
    stackify_transport:
        class: "Stackify\\Log\\Transport\ExecTransport"
        arguments: ["api_key"]
    stackify_handler:
        class: "Stackify\\Log\\Monolog\\Handler"
        arguments: ["application_name", "environment_name", "@stackify_transport"]
monolog:
    handlers:
        stackify:
            type: service
            id: stackify_handler
```

#### Optional Configuration

[](#optional-configuration)

**Proxy**

- ExecTransport supports data delivery through proxy. Specify proxy using [libcurl format](http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html): &lt;\[protocol://\]\[user:password@\]proxyhost\[:port\]&gt;

```
$transport = new ExecTransport($apiKey, ['proxy' => 'https://55.88.22.11:3128']);
```

**Curl path**

- It can be useful to specify `curl` destination path for ExecTransport. This option is set to 'curl' by default.

```
$transport = new ExecTransport($apiKey, ['curlPath' => '/usr/bin/curl']);
```

**Log Server Environment Variables**

- Server environment variables can be added to error log message metadata. **Note:** This will log all system environment variables; do not enable if sensitive information such as passwords or keys are stored this way.

```
$handler = new StackifyHandler('application_name', 'environment_name', $transport, true);
```

Notes
-----

[](#notes)

To get more error details pass Exception objects to the logger if available:

```
try {
    $db->connect();
catch (DbException $ex) {
    // you may use any key name
    $logger->addError('DB is not available', ['ex' => $ex]);
}
```

Additional Configuration
------------------------

[](#additional-configuration)

For additional configurations, you can set on the XML or the PHP File Configuration. Reference for the additional options are located on the stackify logger repository [Stackify PHP Logger - Configuration Settings](stackify/stackify-api-php#configuration-settings)

### Transport Level

[](#transport-level)

- This applies to all the transports `(ExecTransport, CurlTransport, AgentTransport, AgentSocketTransport)`

```
use Monolog\Logger;
use Stackify\Log\Monolog\Handler as StackifyHandler;

$config = array(
       'CaptureServerVariables' => false,
       'CaptureServerVariablesWhitelist' => '*',
       'CaptureServerVariablesBlacklist' => 'REMOTE_ADDR,SERVER_ADDR',
       ...
   );

$transport = new ExecTransport($apiKey, [
   'config' => $config
]);

$handler = new StackifyHandler('application_name', 'environment_name', $transport);
$logger = new Logger('logger');
$logger->pushHandler($handler);
```

### Handler Level

[](#handler-level)

- This applies to the current Monolog Handler

```
use Monolog\Logger;
use Stackify\Log\Monolog\Handler as StackifyHandler;

$transport = new ExecTransport($apiKey); // Your selected transport (Can be null which defaults to AgentSocketTransport)
$logServerVariables = false; // Default
$config = array(
       'CaptureServerVariables' => false,
       'CaptureServerVariablesWhitelist' => '*',
       'CaptureServerVariablesBlacklist' => 'REMOTE_ADDR,SERVER_ADDR',
       ...
);

$handler = new StackifyHandler('application_name', 'environment_name', $transport, $logServerVariables, $config);
$logger = new Logger('logger');
$logger->pushHandler($handler);
```

#### Handler Level Option

[](#handler-level-option)

- **Include Channel**
    - This will include the logger name or the channel set for the log entry.

```
use Monolog\Logger;
use Stackify\Log\Monolog\Handler as StackifyHandler;

$transport = new ExecTransport($apiKey); // Your selected transport (Can be null which defaults to AgentSocketTransport)
$logServerVariables = false; // Default
$config = array(
       'IncludeChannel' => true,
       ...
);

$handler = new StackifyHandler('application_name', 'environment_name', $transport, $logServerVariables, $config);
$logger = new Logger('logger');
$logger->pushHandler($handler);
```

- **Include Extra In Context**
    - This will include the extra property to the context (merging extra to context)

```
use Monolog\Logger;
use Stackify\Log\Monolog\Handler as StackifyHandler;

$transport = new ExecTransport($apiKey); // Your selected transport (Can be null which defaults to AgentSocketTransport)
$logServerVariables = false; // Default
$config = array(
       'IncludeExtraInContext' => true,
       ...
);

$handler = new StackifyHandler('application_name', 'environment_name', $transport, $logServerVariables, $config);
$logger = new Logger('logger');
$logger->pushProcessor(function ($record) {
     if (empty($record['extra'])) {
       $record['extra'] = [];
     }
     $record['extra']['dummy'] = 1;
     return $record;
});
$logger->pushHandler($handler);
```

### Symfony

[](#symfony)

```
services:
    stackify_transport:
        class: "Stackify\\Log\\Transport\\CurlTransport"
        arguments: ["api_key"]
# Square/Curly Brackets
    stackify_handler:
        class: "Stackify\\Log\\Monolog\\Handler"
        arguments: ["application_name", "environment_name", "@stackify_transport", false, { CaptureServerVariables: false, ... }]
# or
# Dash/Colon Space
    stackify_handler:
        class: "Stackify\\Log\\Monolog\\Handler"
        arguments:
            - "application_name"
            - "environment_name"
            - "@stackify_transport"
            - false
            - CaptureServerVariables: false
              CaptureServerWhitelist: "*"
              CaptureServerBlacklist: null

monolog:
    handlers:
        stackify:
            type: service
            id: stackify_handler
```

Troubleshooting
---------------

[](#troubleshooting)

If transport does not work, try looking into `vendor\stackify\logger\src\Stackify\debug\log.log` file (if it is available for writing). Errors are also written to global PHP [error\_log](http://php.net/manual/en/errorfunc.configuration.php#ini.error-log). Note that ExecTransport does not produce any errors at all, but you can switch it to debug mode:

```
$transport = new ExecTransport($apiKey, ['debug' => true]);
```

You can set it also on the `Logger` level. Setting the `Debug` and `DebugLogPath`

```
$config = array(
        'DebugLogPath' => '/path/to/log.log',
        'Debug' => true
    );

$logger = new StackifyHandler('application_name', 'environment_name', $transport, $logServerVariables, $config);
```

License
-------

[](#license)

Copyright 2019 Stackify, LLC.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance51

Moderate activity, may be stable

Popularity38

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~190 days

Recently: every ~31 days

Total

19

Last Release

729d ago

Major Versions

1.1.0 → 2.1.02018-11-28

1.1.1 → 2.2.02019-09-24

1.2.0 → 2.3.02020-11-06

1.3.0 → 2.x-dev2021-04-15

1.x-dev → 3.0.02024-01-17

PHP version history (3 changes)2.0.0PHP ^7.0

2.x-devPHP &gt;=7.0

3.0.0PHP &gt;=8.1

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/7237e87c0bf2f79aa1f9a93bd8df54ce6be9f84d2c0d3c6a8e18c2399dca2580?d=identicon)[tlair-netreo](/maintainers/tlair-netreo)

---

Top Contributors

[![homiedopie](https://avatars.githubusercontent.com/u/6220402?v=4)](https://github.com/homiedopie "homiedopie (20 commits)")[![eric-martin](https://avatars.githubusercontent.com/u/4369260?v=4)](https://github.com/eric-martin "eric-martin (18 commits)")[![darinhoward](https://avatars.githubusercontent.com/u/20421735?v=4)](https://github.com/darinhoward "darinhoward (11 commits)")[![t-lair](https://avatars.githubusercontent.com/u/26470949?v=4)](https://github.com/t-lair "t-lair (6 commits)")[![dimitrytarasov](https://avatars.githubusercontent.com/u/9611704?v=4)](https://github.com/dimitrytarasov "dimitrytarasov (3 commits)")[![jmichaelis](https://avatars.githubusercontent.com/u/10456366?v=4)](https://github.com/jmichaelis "jmichaelis (3 commits)")

---

Tags

monologphpstackifylogpsr-3loggingmonologlog4phpstackify

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[inpsyde/wonolog

Monolog-based logging package for WordPress.

183617.9k7](/packages/inpsyde-wonolog)[logtail/monolog-logtail

Logtail handler for Monolog

233.2M3](/packages/logtail-monolog-logtail)[filips123/monolog-phpmailer

PHPMailer handler for Monolog

1365.6k3](/packages/filips123-monolog-phpmailer)[inpsyde/logzio-monolog

Logz.io integration for Monolog

191.2M1](/packages/inpsyde-logzio-monolog)[mero/yii2-monolog

The Monolog integration for the Yii framework.

42186.1k](/packages/mero-yii2-monolog)[alexandre-daubois/monolog-processor-collection

A collection of Monolog processors

1516.6k](/packages/alexandre-daubois-monolog-processor-collection)

PHPackages © 2026

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