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

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

ipagdevs/monolog-discord-handler
================================

1.0.4(1mo ago)08↓100%MITPHPPHP ^8.3CI passing

Since Apr 13Pushed 1mo agoCompare

[ Source](https://github.com/ipagdevs/monolog-discord-handler)[ Packagist](https://packagist.org/packages/ipagdevs/monolog-discord-handler)[ RSS](/packages/ipagdevs-monolog-discord-handler/feed)WikiDiscussions master Synced 1w ago

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

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

[](#monolog-discord-handler)

[![Latest Version on Packagist](https://camo.githubusercontent.com/834f4828ecf2ab33aaf8d0609380c0ef67f0fc426cdaafdbf125672640c7ec92/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f69706167646576732f6d6f6e6f6c6f672d646973636f72642d68616e646c65722e737667)](https://packagist.org/packages/ipagdevs/monolog-discord-handler)[![Total Downloads](https://camo.githubusercontent.com/7049b5f79d678122de2b202b276bacf870547c1a3410810831b8e365c08d858f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f69706167646576732f6d6f6e6f6c6f672d646973636f72642d68616e646c65722e737667)](https://packagist.org/packages/ipagdevs/monolog-discord-handler)[![License](https://camo.githubusercontent.com/9929ed3789f0e5a0155851e7883dfac6837a7c05b718695fc35cffe8f76f2d6d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f69706167646576732f6d6f6e6f6c6f672d646973636f72642d68616e646c65722e737667)](https://packagist.org/packages/ipagdevs/monolog-discord-handler)[![PHP Version](https://camo.githubusercontent.com/6a7e44f173fd10d81831229058e3e092eb4deeee82d358834c55b7809c123a55/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f69706167646576732f6d6f6e6f6c6f672d646973636f72642d68616e646c65722f706870)](https://packagist.org/packages/ipagdevs/monolog-discord-handler)[![Build Status](https://github.com/ipagdevs/monolog-discord-handler/actions/workflows/test.yml/badge.svg)](https://github.com/ipagdevs/monolog-discord-handler/actions/workflows/test.yml)

Send Monolog logs directly to a Discord webhook using rich embeds, automatic formatting, and safe value normalization.

---

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

[](#installation)

```
composer require ipagdevs/monolog-discord-handler
```

---

Usage (Plain Monolog)
---------------------

[](#usage-plain-monolog)

```
use Monolog\Logger;
use Monolog\Level;
use IpagDevs\Logging\DiscordHandler;

$logger = new Logger('app');

$logger->pushHandler(
    new DiscordHandler(
        webhook_url: 'https://discord.com/api/webhooks/xxx',
        level: Level::Debug
    )
);

$logger->error('System error occurred', [
    'user_id' => 123,
    'exception' => new RuntimeException('Critical failure'),
]);
```

---

How it works
------------

[](#how-it-works)

The handler automatically:

- Converts logs into Discord embeds
- Respects Discord field and message limits
- Normalizes values:

    - array/object → pretty JSON
    - Throwable → formatted stacktrace block
    - Closure → callable\[closure\]
    - string callables → callable:method
- Safely truncates large payloads
- Prevents application crashes (fail-safe HTTP handling)

---

Laravel Usage
-------------

[](#laravel-usage)

In `config/logging.php`:

```
'channels' => [
    'discord' => [
        'driver' => 'monolog',
        'handler' => IpagDevs\Logging\DiscordHandler::class,
        'with' => [
            'webhook_url' => env('DISCORD_WEBHOOK_URL'),
        ],
        'level' => 'debug',
    ],
],
```

In `.env`:

```
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/xxx
```

---

Example
-------

[](#example)

```
Log::error('Payment failed', [
    'order_id' => 999,
    'user' => [
        'id' => 1,
        'name' => 'Lucas',
    ],
    'exception' => new RuntimeException('Gateway timeout'),
]);
```

This will be sent to Discord as an embed with:

- log level as title
- message as description
- context automatically converted into fields

---

Safety
------

[](#safety)

This handler is designed to be safe by default:

- never throws exceptions outside the handler
- never blocks application execution
- ignores HTTP failures silently

---

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance89

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

5

Last Release

54d ago

### Community

Maintainers

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

---

Top Contributors

[![lucasmilhoranca-ipag](https://avatars.githubusercontent.com/u/207579449?v=4)](https://github.com/lucasmilhoranca-ipag "lucasmilhoranca-ipag (10 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.7k532.1M19.2k](/packages/laravel-framework)[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k11](/packages/tempest-framework)[spatie/flare-client-php

Send PHP errors to Flare

177156.9M21](/packages/spatie-flare-client-php)[pantheon-systems/terminus

A command line interface for Pantheon

3391.5M17](/packages/pantheon-systems-terminus)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9017.2k55](/packages/open-dxp-opendxp)

PHPackages © 2026

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