jspapp/monolog-discord-handler

A Monolog handler for Discord

Installs: 92

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 2

Open Issues: 4

pkg:composer/jspapp/monolog-discord-handler

2.0.1 2018-08-09 14:30 UTC

This package is not auto-updated.

Last update: 2026-01-13 23:34:38 UTC


README

Installation

composer require jspapp/monolog-discord-handler

Usage

<?php

require 'vendor/autoload.php';

use jspapp\MonologDiscord\DiscordHandler;

$webhook = 'Your Webhook URL';

$log = new Monolog\Logger('discord');
$log->pushHandler(new DiscordHandler($webhook, Logger::INFO));

$log->info('This is the title!', [
  'Information' => 'Context data will be shown as embedded information.',
  'Additional' => 'The footer of the card also displays the logger\'s name and error level, along with the event\'s timestamp.'
]);

Sample image

Laravel Log Driver

Import the log driver into config/logging.php:

use jspapp\MonologDiscord\Laravel\DiscordChannel;

and add the following driver configuration:

'discord' => [
  'driver' => 'custom',
  'via' => DiscordChannel::class,
  'webhook' => env('LOG_DISCORD_WEBHOOK'),
],

Rate Limit Note

I did what I could to respect Discord's rate limit, but adding the driver to Laravel's default log stack gave me issues. Use with caution in production environments, and consider selectively using:

Log::channel('discord')->info('Message');

instead of catching everything.