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

v1.1.0 2018-11-12 21:45 UTC


codecov Build Status SensioLabsInsight MIT licensed


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

It has some bugs

  • Slack accepts until 2000 chars for see


  • Although Monolog has the WhatFailureGroupHandler I would consider it simpler not to wrap my handler around another handler and have a simpler and faster logic see
  • SlackWebhookHandler does not have timeouts and it executes retries when slack service is down see


  • Current package gives you the ability to add a custom formatter to the handler in order to format Attachments. Although you can pass a formatter to Slack Handlers of monolog the formatter is applied only to simple messages of slack and they are not executed for Attachments.
  • I like the formatting that I created better than the one that monolog has.


You can install this package through composer

$ composer require webthink/monolog-slack


Simple initialization

You can initialize a SlackWebhookHandler simple with the following lines:

$handler = new SlackWebhookHandler('your_webhook_url');

Inject custom formatter

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


Note that the formatter passed inside the slack handler must be an instance of SlackFormatterInterface.

If you do not pass a custom Formatter SlackWebhookHandler users the SlackLineFormatter by default.

Initialize with a custom HTTP Client.

Inside SlackWebhookHandler you can inject your custom Custom HTTP client. The client that is injected must implement a \Webthink\MonologSlack\Utility\ClientInterface.

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

Change log

Please see CHANGELOG for more information what has changed recently.


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


  • Use a PSR-18 client instead of a custom one.