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

ActiveMonolog-handler[Logging &amp; Monitoring](/categories/logging)

webthink/monolog-slack
======================

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

v2.1.0(6y ago)11103.7k—2.8%7[1 PRs](https://github.com/gmponos/monolog-slack/pulls)MITPHPPHP ^7.2CI failing

Since Mar 24Pushed 5y ago2 watchersCompare

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

READMEChangelog (9)Dependencies (6)Versions (15)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)

**Notice** I have created another package that contains a collection of Monolog handlers that can send your logs using a PSR-18 clients. The package is [monolog-http](https://github.com/monolog-http/monolog-http)

I will focus my efforts on the package above. If you are using the current package let me know WDYT.

Give a ⭐ to monolog-http if you like it.

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.

**Flexibility**

- The Handler on this package allows you to pass your own PSR-18 client that can be configured in your own way.

**Performance**

- SlackWebhookHandler does not have timeouts and it executes retries when slack service is down [see](https://github.com/Seldaek/monolog/pull/846#issuecomment-373522968)Because you are allowed to pass your own PSR-18 client you can have it configured in your own way.

**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 own custom formatters. I like the formatting of Slack Records that I have 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:

```
$client = new PSR18Client(); // PSR18Client does not exist. Use your own implementation.
$requestFactory = new PSR17RequestFactory(); // PSR18Client does not exist. Use your own implementation.
$handler = new SlackWebhookHandler($client, $requestFactory, 'your_webhook_url');
```

Formatters
----------

[](#formatters)

### Inject custom formatter

[](#inject-custom-formatter)

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

`$handler->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 uses the `SlackLineFormatter` by default.

### 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)

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

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 96% 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 ~78 days

Recently: every ~39 days

Total

11

Last Release

2193d ago

Major Versions

v0.3.0 → v1.0.02018-09-16

v1.3.0 → 2.x-dev2019-12-15

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

2.x-devPHP ^7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5675248?v=4)[Mponos George](/maintainers/gmponos)[@gmponos](https://github.com/gmponos)

---

Top Contributors

[![gmponos](https://avatars.githubusercontent.com/u/5675248?v=4)](https://github.com/gmponos "gmponos (72 commits)")[![rmikalkenas](https://avatars.githubusercontent.com/u/14221532?v=4)](https://github.com/rmikalkenas "rmikalkenas (2 commits)")[![tomasz-adamczyk](https://avatars.githubusercontent.com/u/62649417?v=4)](https://github.com/tomasz-adamczyk "tomasz-adamczyk (1 commits)")

---

Tags

logloggerloggingmonologmonolog-handlerphpphp7slackslack-webhook

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.1k23.1k9](/packages/tempest-framework)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

81733.7k](/packages/flow-php-flow)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2322.9M248](/packages/open-telemetry-sdk)[nipwaayoni/elastic-apm-php-agent

A php agent for Elastic APM v2 Intake API

30694.2k6](/packages/nipwaayoni-elastic-apm-php-agent)[scoutapp/scout-apm-php

Scout Application Performance Monitoring Agent - https://scoutapm.com

17877.0k5](/packages/scoutapp-scout-apm-php)[pagemachine/typo3-formlog

Form log for TYPO3

23225.3k6](/packages/pagemachine-typo3-formlog)

PHPackages © 2026

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