PHPackages                             thedomeffm/monolog-discord-handler-bundle - 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. thedomeffm/monolog-discord-handler-bundle

ActiveSymfony-bundle[Logging &amp; Monitoring](/categories/logging)

thedomeffm/monolog-discord-handler-bundle
=========================================

Monolog handler to push your logs to discord via webhook

v1.0.0(1y ago)22.8k1MITPHPPHP &gt;=8.1CI passing

Since Dec 3Pushed 1y agoCompare

[ Source](https://github.com/thedomeffm/MonologDiscordHandlerBundle)[ Packagist](https://packagist.org/packages/thedomeffm/monolog-discord-handler-bundle)[ Docs](https://github.com/thedomeffm/MonologDiscordHandlerBundle)[ RSS](/packages/thedomeffm-monolog-discord-handler-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (8)Used By (0)

Monolog Discord Handler
=======================

[](#monolog-discord-handler)

Adds a handler to monolog which can post your logs directly via discord webhook to your discord server channel.

Note

Discord has a character limit of 2000 (or 4000 when you have nitro). The message will get truncated when needed.

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

[](#installation)

`composer require thedomeffm/monolog-discord-handler-bundle`

Configure the bundle
--------------------

[](#configure-the-bundle)

I've not added a recipe (or whatever I need to create 🤷), so you need to create the config by yourself.

```
# .env
DISCORD_WEBHOOK_URL=""

```

### Minimal

[](#minimal)

```
# config/packages/thedomeffm_monolog_discord_handler.yaml
thedomeffm_monolog_discord_handler:
    discord:
        webhook_url: "%env(DISCORD_WEBHOOK_URL)%"
```

### Maximal

[](#maximal)

Note

Have in mind that json\_pretty\_print makes the message longer, and you'll reach the discord char limit easier!

```
# config/packages/thedomeffm_monolog_discord_handler.yaml
thedomeffm_monolog_discord_handler:
    discord:
        webhook_url: "%env(DISCORD_WEBHOOK_URL)%"

    formatting:
        characters_limit: 2000
        date_format: 'd.m.Y H:i:s'
        json_pretty_print: false
```

Configure monolog
-----------------

[](#configure-monolog)

Add the "service" handler

```
# monolog.yaml
monolog:
    handlers:
        # your other handlers...
        discord:
            type: service
            id: thedomeffm_monolog_discord_handler
```

Here is an example how a production config could look like:

```
# monolog.yaml
when@prod:
    monolog:
        handlers:
            main:
                type: fingers_crossed
                action_level: error
                handler: main_group
                excluded_http_codes: [404, 405]
                buffer_size: 50

            main_group:
                type: group
                members: ['error_stream', 'discord']

            error_stream:
                type: stream
                path: php://stderr
                level: debug
                formatter: monolog.formatter.json

            discord:
                type: service
                id: thedomeffm_monolog_discord_handler

            # your other handler...
```

Override the message content
----------------------------

[](#override-the-message-content)

Unhappy with my opinionated message design? Then decorate the factory. You can pass strings or the Text class into the Discord message.

```
// ...
use Monolog\LogRecord;
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use TheDomeFfm\MonologDiscordHandlerBundle\Message\DiscordMessage;
use TheDomeFfm\MonologDiscordHandlerBundle\Message\DiscordMessageFactoryInterface;
use TheDomeFfm\MonologDiscordHandlerBundle\Message\Syntax;
use TheDomeFfm\MonologDiscordHandlerBundle\Message\Text;

#[AsDecorator(decorates: 'thedomeffm_monolog_discord_message_factory')]
class CustomMessageFactory implements DiscordMessageFactoryInterface
{
    public function createFromLogRecord(LogRecord $record): DiscordMessage
    {
        $message = new DiscordMessage();

        $message->append('# :x: Ohh noo an error!\n');
        $message->append(Text::create(Syntax::Code, $record->message)->render());

        return $message;
    }
}
```

[![custom discord error message from error log](custom_error_message.png "Custom Error")](custom_error_message.png)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance48

Moderate activity, may be stable

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.8% 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 ~101 days

Recently: every ~126 days

Total

6

Last Release

385d ago

Major Versions

v0.0.5 → v1.0.02025-04-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d5ceb20b0dbb97f2efa3a6e54eaebf27baba1fa06c8ec9ee18e6c56ee1752f7?d=identicon)[thedomeffm](/maintainers/thedomeffm)

---

Top Contributors

[![thedomeffm](https://avatars.githubusercontent.com/u/29406401?v=4)](https://github.com/thedomeffm "thedomeffm (9 commits)")[![renjinsk](https://avatars.githubusercontent.com/u/456717?v=4)](https://github.com/renjinsk "renjinsk (2 commits)")

---

Tags

loggingmonologdiscord

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thedomeffm-monolog-discord-handler-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/thedomeffm-monolog-discord-handler-bundle/health.svg)](https://phpackages.com/packages/thedomeffm-monolog-discord-handler-bundle)
```

###  Alternatives

[symfony/monolog-bundle

Symfony MonologBundle

2.9k249.1M1.6k](/packages/symfony-monolog-bundle)[lefuturiste/monolog-discord-handler

A simple monolog handler for support Discord webhooks

34111.6k4](/packages/lefuturiste-monolog-discord-handler)

PHPackages © 2026

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