Skip to content

mvanhonk/laravel-post-errors-to-discord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Discord Logger for Laravel

This package provides a custom logger for Laravel that sends error logs to a Discord channel.

Requirements

  • Laravel version 11.x or higher.

Installation

  1. Copy DiscordLogger.php to your app/Logging/ directory.
  2. Add the configuration from logging_config.php to your config/logging.php file.
  3. Add the environment variables from .env.example to your .env file and fill in the values.
  4. Install Guzzle if you haven't already: composer require guzzlehttp/guzzle
  5. Update your exception handler (app/Exceptions/Handler.php or bootstrap/app.php for Laravel 11+) to use the Discord logger:
use Illuminate\Support\Facades\Log;

// ... other code ...

$this->reportable(function (\Throwable $e) {
    Log::channel('discord')->error($e->getMessage(), ['exception' => $e]);
});

within

->withExceptions(function (Exceptions $exceptions) {
        //place here
    }

Now your Laravel application will log errors to Discord.

Usage

Test before using. Repository: github respository

About

Post laravel errors to discord via webhook

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages