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

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

drbiko/monolog-slack
====================

This package contains handlers/processors for sending logs of monolog to a slack channel.

v1.1.2(7y ago)031MITPHPPHP ^7.0

Since Mar 24Pushed 7y agoCompare

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

READMEChangelogDependencies (4)Versions (11)Used By (0)

Send logs to Slack using Monolog
================================

[](#send-logs-to-slack-using-monolog)

[![codecov](https://camo.githubusercontent.com/278cd4eb1d9f300565cdbaabce597e36e13f782a005cc3c82188d4c4ea2c9457/68747470733a2f2f636f6465636f762e696f2f67682f676d706f6e6f732f6d6f6e6f6c6f672d736c61636b2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/gmponos/monolog-slack)[![Build Status](https://camo.githubusercontent.com/e2366ebf6b900624304c282059a24edd495838c6dfffda8c2109707924bc4601/68747470733a2f2f7472617669732d63692e6f72672f676d706f6e6f732f6d6f6e6f6c6f672d736c61636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/gmponos/monolog-slack)[![SensioLabsInsight](https://camo.githubusercontent.com/37478d9f1d6090787c2fda529016aa71a8f9939a6f556be1f2808176b5d2106f/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f32626134636537642d636463652d343432342d616536622d6465616530313037626163652f6d696e692e706e67)](https://insight.sensiolabs.com/projects/2ba4ce7d-cdce-4424-ae6b-deae0107bace)[![MIT licensed](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/gmponos/monolog-slack/blob/master/LICENSE.md)

Description
-----------

[](#description)

This is a package that can help you send logs through monolog to Slack using webhooks. Monolog already has a handler for Slack using Webhooks but I am not in favor of it for these reasons:

**It has some bugs**

- Slack accepts 2000 characters. For more details [see](https://github.com/Seldaek/monolog/issues/909). Current package is not able to send more than 2000 characters but it is able to send until 2000 characters and be well formatted.

**Performance**

- Monolog has the `WhatFailureGroupHandler` but I consider it simpler not to wrap my handler around another handler and have a simpler and faster logic [see](https://github.com/Seldaek/monolog/issues/920)
- SlackWebhookHandler does not have timeouts and it executes retries when slack service is down [see](https://github.com/Seldaek/monolog/pull/846#issuecomment-373522968)

**Formatting**

- Current package gives you the ability to add a custom formatter to the `SlackwebhookHandler` in order to format Attachments. Monolog allows you to pass a formatter to SlackHandlers but the formatter is applied only to simple messages of slack and they are not applied for Attachments.
- I have created my custom formatters and I tend to like the formatting of Slack Records that I have created more than the one that monolog has.

Install
-------

[](#install)

You can install this package through composer

```
$ composer require webthink/monolog-slack

```

Documentation
-------------

[](#documentation)

### Simple initialization

[](#simple-initialization)

You can initialize a `SlackWebhookHandler` simple with the following lines:

`$handler = new SlackWebhookHandler('your_webhook_url');`

Formatters
----------

[](#formatters)

### Inject custom formatter

[](#inject-custom-formatter)

Now if you need to pass a custom slack formatter then you need to do the following:

`$hanlder->setFormatter($yourFormatter);`

- **Note-1:** The formatter passed inside the slack handler must be an instance of `SlackFormatterInterface`.
- **Note-2:** If you do not pass a custom Formatter SlackWebhookHandler users the `SlackLineFormatter` by default.
- **Note-3:** Some of the settings passed during constructing the Handler are overridden by the Formatter passed.

### SlackLineFormatter

[](#slacklineformatter)

[![slacklineformatter](docs/slacklineformatter.PNG)](docs/slacklineformatter.PNG)

### SlackShortAttachmentFormatter

[](#slackshortattachmentformatter)

[![slackshortattachementformatter](docs/slackshortattachementformatter.PNG)](docs/slackshortattachementformatter.PNG)

### SlackLongAttachmentFormatter

[](#slacklongattachmentformatter)

[![slacklongattachementformatter](docs/slacklongattachementformatter.PNG)](docs/slacklongattachementformatter.PNG)

HTTP Client.
------------

[](#http-client)

### Initialize with a PSR-18 HTTP Client.

[](#initialize-with-a-psr-18-http-client)

Inside `SlackWebhookHandler` you can inject your [PSR-18](https://www.php-fig.org/psr/psr-18) HTTP client.

```
$handler = new SlackWebhookHandler('your_webhook_url', null, null, LogLevel::ERROR, true, $client);`
```

If no PSR-18 HTTP client is passed as argument then `SlackwebhookHandler` initializes a `\Http\Adapter\Guzzle6\Client` by default. The initialized client has Timeout and Connection-Timeout to 1 second.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

1. Run `composer install` from bash.
2. Run `composer tests` from bash.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 91.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 ~53 days

Total

8

Last Release

2597d ago

Major Versions

v0.3.0 → v1.0.02018-09-16

v1.1.0 → 2.x-dev2018-12-19

PHP version history (2 changes)v0.1.0PHP ^7.1

v1.1.2PHP ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5f252dd9b69af363b1c85d0f6739fc831c5fe7affe53212dff8ead0d85f099f0?d=identicon)[drbiko](/maintainers/drbiko)

---

Top Contributors

[![gmponos](https://avatars.githubusercontent.com/u/5675248?v=4)](https://github.com/gmponos "gmponos (51 commits)")[![drbiko](https://avatars.githubusercontent.com/u/48100596?v=4)](https://github.com/drbiko "drbiko (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[symfony/monolog-bridge

Provides integration for Monolog with various Symfony components

2.6k189.7M257](/packages/symfony-monolog-bridge)[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M81](/packages/rollbar-rollbar)[illuminate/log

The Illuminate Log package.

6224.3M517](/packages/illuminate-log)[honeybadger-io/honeybadger-php

Honeybadger PHP library

381.5M4](/packages/honeybadger-io-honeybadger-php)[graycore/magento2-stdlogging

A Magento 2 module that changes all logging handlers to stdout

2382.6k](/packages/graycore-magento2-stdlogging)

PHPackages © 2026

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