Logging is one of the most crucial part of any laravel application which helps developer understand what’s happening behind the scenes. So, in this guide, we will explore how we can send laravel logs to discord step by step.
The log file is generally stored in storage/logs/laravel.log file but sometimes it is not enough. Specially incase of production, when an error occurs, it is difficult to dig on the file. So, we will see how we can send instant alert of laravel logs to discord.
Install Package
To send instant logging alert on discord, we will be using a package: marvinlabs/laravel-discord-logger. So, to install the package in your system, enter the following command:
composer require marvinlabs/laravel-discord-logger
Setup Config file
After installation of package, we need to add a new channel on our config/logging.php file. Just copy the following information.
// config/logging.php
'channels' => [
//...
'discord' => [
'driver' => 'custom',
'via' => MarvinLabs\DiscordLogger\Logger::class,
'level' => 'debug', // manage your log level..
'url' => env('DISCORD_WEBHOOK_URL'),
'ignore_exceptions' => env('LOG_DISCORD_IGNORE_EXCEPTIONS', false),
],
];
After adding this, you just need to define the DISCORD_WEBHOOK_URL in your .env file.
Setup discord
Now in discord, its a very simple step. You will first create a server and create one channel. Go to the settings of channel, you will see the Integrations option and then Webhooks. Just copy the webhook url and paste it on your .env.

Further Information
So, above setup will perfectly work. And in addition to that, you can add as many as log channels. For eg. You may want a separate channel to log payment information. THen you can duplicate your channel config like this:
// config/logging.php
'channels' => [
//...
'discord-payment' => [
'driver' => 'custom',
'via' => MarvinLabs\DiscordLogger\Logger::class,
'level' => 'debug', // manage your log level..
'url' => env('DISCORD_PAYMENT_LOG_WEBHOOK_URL'),
'ignore_exceptions' => env('LOG_DISCORD_IGNORE_EXCEPTIONS', false),
],
];
And in the same way, you can setup new web hook url and paste that.
Not only discord, you can setup your laravel logging to send logs in other platforms like google-chat, slack, sentry and much more.
Also read about laravel polymorphic relation here.