PHPackages                             renslabs/laravel-logger-discord-channel - 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. renslabs/laravel-logger-discord-channel

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

renslabs/laravel-logger-discord-channel
=======================================

A Discord based Monolog driver for Laravel

v1.0.3(7mo ago)1476↑33.3%1MITPHPPHP ^7.2.5|^8.0CI passing

Since Aug 17Pushed 7mo agoCompare

[ Source](https://github.com/renslabs/laravel-logger-discord-channel)[ Packagist](https://packagist.org/packages/renslabs/laravel-logger-discord-channel)[ RSS](/packages/renslabs-laravel-logger-discord-channel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (5)Versions (5)Used By (0)

[![](https://camo.githubusercontent.com/f8bee4c6040c49ec8b3556120e13642efc79aaba7007f63692c17d3e08a23fc3/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2532304c6f67676572253230446973636f72642532304368616e6e656c2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d72656e736c6162732532466c61726176656c2d6170692d726573706f6e73652d666f726d6174746572267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d412b706f77657266756c2b446973636f72642d62617365642b4d6f6e6f6c6f672b6472697665722b666f722b4c61726176656c2b746861742b73656e64732b726963682532432b64657461696c65642b6c6f672b6d657373616765732b746f2b446973636f72642b6368616e6e656c732b7669612b776562686f6f6b732e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)](https://camo.githubusercontent.com/f8bee4c6040c49ec8b3556120e13642efc79aaba7007f63692c17d3e08a23fc3/68747470733a2f2f62616e6e6572732e6265796f6e64636f2e64652f4c61726176656c2532304c6f67676572253230446973636f72642532304368616e6e656c2e706e673f7468656d653d6c69676874267061636b6167654d616e616765723d636f6d706f7365722b72657175697265267061636b6167654e616d653d72656e736c6162732532466c61726176656c2d6170692d726573706f6e73652d666f726d6174746572267061747465726e3d617263686974656374267374796c653d7374796c655f31266465736372697074696f6e3d412b706f77657266756c2b446973636f72642d62617365642b4d6f6e6f6c6f672b6472697665722b666f722b4c61726176656c2b746861742b73656e64732b726963682532432b64657461696c65642b6c6f672b6d657373616765732b746f2b446973636f72642b6368616e6e656c732b7669612b776562686f6f6b732e266d643d312673686f7757617465726d61726b3d3026666f6e7453697a653d313030707826696d616765733d68747470732533412532462532466c61726176656c2e636f6d253246696d672532466c6f676f6d61726b2e6d696e2e737667)

Laravel Discord Logger Channel
==============================

[](#laravel-discord-logger-channel)

A powerful Discord-based Monolog driver for Laravel that sends rich, detailed log messages to Discord channels via webhooks.

🚀 Requirements
--------------

[](#-requirements)

- **PHP**: ^7.2.5 | ^8.0
- **Laravel**: ^7.0 | ^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0
- **GuzzleHttp**: ^7.0
- **Discord**: Webhook URL with appropriate permissions

✨ Features
----------

[](#-features)

### 🚀 Core Features

[](#-core-features)

- **Easy Installation**: One-command setup with auto-configuration
- **Multiple Log Levels**: Complete support for all Monolog levels with color coding
- **Environment Control**: Smart environment-based logging activation
- **Rich Context**: Comprehensive information collection and formatting
- **Professional UI**: Beautiful Discord embeds with emojis and color coding

### 🔧 Advanced Features

[](#-advanced-features)

- **Built-in Commands**: Status check, testing, and installation commands
- **Web Interface**: Interactive testing panel with real-time results
- **API Routes**: RESTful endpoints for programmatic testing
- **Exception Handling**: Detailed exception information with stack traces
- **Request Tracking**: Complete HTTP request information capture
- **User Context**: Automatic user identification and tracking
- **Memory Monitoring**: System resource usage tracking
- **Smart Formatting**: Automatic JSON formatting for complex data

### 🛡️ Enterprise Ready

[](#️-enterprise-ready)

- **Robust Error Handling**: Silent failure mode prevents app crashes
- **Performance Optimized**: Field limits and efficient data processing
- **Security Features**: Sensitive data filtering and path sanitization
- **Configurable Limits**: Customizable field and message length limits

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

[](#installation)

### Via Composer

[](#via-composer)

```
composer require renslabs/laravel-logger-discord-channel
```

### Auto-Configuration

[](#auto-configuration)

Run the install command to automatically configure the package:

```
php artisan logger:discord-install
```

This will:

- Add Discord channel configuration to `config/logging.php`
- Add environment variables to `.env`
- Show next steps for setup

### Manual Configuration

[](#manual-configuration)

If you prefer manual setup, add this to your `config/logging.php` channels array:

```
'discord' => [
    'driver' => 'custom',
    'via' => \renslabs\LoggerDiscordChannel\DiscordLogger::class,
    'level' => env('DISCORD_LOG_LEVEL', 'debug'),
    'webhook' => env('DISCORD_WEBHOOK_URL'),
    'message' => env('DISCORD_MESSAGE', null),
    'context' => env('DISCORD_INCLUDE_CONTEXT', false),
    'suffix' => env('DISCORD_LOG_SUFFIX', config('app.name')),
    'environment' => ['production', 'staging', 'local'],
    'max_field_length' => env('DISCORD_MAX_FIELD_LENGTH', 1024),
    'max_description_length' => env('DISCORD_MAX_DESCRIPTION_LENGTH', 4000),
],
```

Add these environment variables to your `.env` file:

```
# Basic Configuration
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_URL
DISCORD_LOG_LEVEL=info
DISCORD_INCLUDE_CONTEXT=true
DISCORD_MAX_FIELD_LENGTH=1024
DISCORD_MAX_DESCRIPTION_LENGTH=4000
```

🚀 Usage
-------

[](#-usage)

### Environment Configuration

[](#environment-configuration)

#### Laravel 11+ Configuration

[](#laravel-11-configuration)

For Laravel 11 and above, simply update your `.env` file:

```
# Enable stack logging with multiple channels
LOG_CHANNEL=stack
LOG_STACK=single,discord

# Discord Configuration
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_URL
DISCORD_LOG_LEVEL=info
DISCORD_INCLUDE_CONTEXT=true
DISCORD_MAX_FIELD_LENGTH=1024
DISCORD_MAX_DESCRIPTION_LENGTH=4000
```

#### Laravel 10 and Below Configuration

[](#laravel-10-and-below-configuration)

For Laravel 10 and below, you need to update both your `config/logging.php` and `.env` files:

**1. Update `config/logging.php`:**

```
'channels' => [
    'stack' => [
        'driver' => 'stack',
        'channels' => ['single', 'discord'],
        'ignore_exceptions' => false,
    ],

    // ... other channels

    'discord' => [
        'driver' => 'custom',
        'via' => \renslabs\LoggerDiscordChannel\DiscordLogger::class,
        'level' => env('DISCORD_LOG_LEVEL', 'debug'),
        'webhook' => env('DISCORD_WEBHOOK_URL'),
        'message' => env('DISCORD_MESSAGE', null),
        'context' => env('DISCORD_INCLUDE_CONTEXT', false),
        'suffix' => env('DISCORD_LOG_SUFFIX', config('app.name')),
        'environment' => ['production', 'staging', 'local'],
        'max_field_length' => env('DISCORD_MAX_FIELD_LENGTH', 1024),
        'max_description_length' => env('DISCORD_MAX_DESCRIPTION_LENGTH', 4000),
    ],
],
```

**2. Update your `.env` file:**

```
# Use stack logging
LOG_CHANNEL=stack

# Discord Configuration
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_URL
DISCORD_LOG_LEVEL=info
DISCORD_INCLUDE_CONTEXT=true
DISCORD_MAX_FIELD_LENGTH=1024
DISCORD_MAX_DESCRIPTION_LENGTH=4000
```

### Basic Usage

[](#basic-usage)

```
use Illuminate\Support\Facades\Log;

// Simple error logging
Log::error('Payment processing failed', [
    'userId' => auth()->id(),
    'amount' => 99.99,
    'payment_method' => 'credit_card'
]);

// Info with rich context
Log::info('User registered successfully', [
    'userId' => $user->id,
    'email' => $user->email,
    'source' => 'web_registration',
    'metadata' => [
        'referrer' => request()->header('referer'),
        'ip' => request()->ip()
    ]
]);

// Exception with full context
try {
    $this->processPayment($request);
} catch (Exception $e) {
    Log::critical('Payment system failure', [
        'exception' => $e,
        'userId' => auth()->id(),
        'request_data' => $request->except(['password', 'card_number']),
        'system_load' => sys_getloadavg()[0]
    ]);
}
```

🔧 Available Commands
--------------------

[](#-available-commands)

### Installation &amp; Setup

[](#installation--setup)

```
php artisan logger:discord-install          # Auto-configure package
php artisan logger:discord-install --force  # Overwrite existing config
```

### Status &amp; Diagnostics

[](#status--diagnostics)

```
php artisan logger:discord-status           # Comprehensive status check
```

**Checks:**

- ✅ Package installation and class loading
- ⚙️ Configuration validation
- 🌐 Webhook connectivity testing
- 🌍 Environment settings verification
- 💾 Memory and system information

### Testing &amp; Validation

[](#testing--validation)

```
php artisan logger:discord-test                    # Test with default level (info)
php artisan logger:discord-test --level=error      # Test error level
php artisan logger:discord-test --level=warning    # Test warning level
php artisan logger:discord-test --level=info       # Test info level
```

⚙️ Configuration Options
------------------------

[](#️-configuration-options)

### Basic Configuration

[](#basic-configuration)

OptionDescriptionDefaultExample`level`Minimum log level to send`debug``error`, `warning`, `info``webhook`Discord webhook URLRequired`https://discord.com/api/webhooks/...``message`Custom message prefix`null``"🚨 Alert from MyApp"``context`Include full context/stacktrace`false``true`, `false``suffix`Suffix for log titleApp name`"Production Server"``environment`Environments where logging is active`['production', 'staging', 'local']``['production']`### Advanced Configuration

[](#advanced-configuration)

OptionDescriptionDefaultPurpose`max_field_length`Maximum Discord field value length`1024`Prevent API errors`max_description_length`Maximum embed description length`4000`Discord API limit📊 Log Levels &amp; Visual Design
--------------------------------

[](#-log-levels--visual-design)

### Supported Log Levels

[](#supported-log-levels)

LevelPriorityEmojiColorUse Case`emergency`600🚨Dark RedSystem unusable`alert`550🔴RedImmediate action required`critical`500💥Orange RedCritical conditions`error`400❌RedRuntime errors`warning`300⚠️OrangeExceptional occurrences`notice`250🔔BlueNormal but significant`info`200ℹ️GreenInteresting events`debug`100🔍GrayDetailed debug info**Important**: Only logs at or above the configured level will be sent to Discord.

📱 Rich Discord Message Format
-----------------------------

[](#-rich-discord-message-format)

### Main Embed Structure

[](#main-embed-structure)

- **Professional Title**: Emoji + Log Level + App Name
- **Color-Coded**: Different colors for each log level
- **Structured Fields**: Organized information display
- **Timestamp**: ISO 8601 format with timezone
- **Footer**: App branding with Laravel logo

### Comprehensive Information Capture

[](#comprehensive-information-capture)

#### 🌍 System Information

[](#-system-information)

- Environment (local/staging/production)
- Memory usage (formatted)
- Log channel name
- Timestamp with timezone

#### 🌐 Request Information (Web Requests)

[](#-request-information-web-requests)

- Full URL with parameters
- HTTP method (GET, POST, etc.)
- Client IP address
- User agent string
- Referer header

#### 👤 User Context

[](#-user-context)

- Custom user ID from context
- Authenticated user (ID + email)
- Session information

#### 💥 Exception Details

[](#-exception-details)

- Exception class name
- File path and line number (sanitized)
- Exception code
- Previous exception chain
- Stack trace (if context enabled)

#### 📋 Custom Context

[](#-custom-context)

- All context data with smart formatting
- JSON formatting for complex objects
- Automatic field organization
- Length limits for Discord compatibility

### Context Embed (Optional)

[](#context-embed-optional)

When `context` is enabled, a separate embed shows:

- Complete context data
- Extra Monolog fields
- JSON formatted for readability
- Proper syntax highlighting

🌍 Best Practices
----------------

[](#-best-practices)

### Recommended Settings by Environment

[](#recommended-settings-by-environment)

#### Production

[](#production)

```
DISCORD_LOG_LEVEL=error
DISCORD_INCLUDE_CONTEXT=false
DISCORD_MAX_FIELD_LENGTH=512
```

#### Staging

[](#staging)

```
DISCORD_LOG_LEVEL=warning
DISCORD_INCLUDE_CONTEXT=true
DISCORD_MAX_FIELD_LENGTH=1024
```

#### Development

[](#development)

```
DISCORD_LOG_LEVEL=debug
DISCORD_INCLUDE_CONTEXT=true
DISCORD_MAX_FIELD_LENGTH=1024
```

🛡️ Security &amp; Performance
-----------------------------

[](#️-security--performance)

### Security Features

[](#security-features)

- ✅ **Path Sanitization**: Base path stripped from file paths
- ✅ **Length Limits**: Prevent Discord API overflow
- ✅ **Silent Failure**: Won't crash your application
- ✅ **Timeout Protection**: 10-second HTTP timeout
- ✅ **Sensitive Data**: Easy to exclude sensitive fields

### Performance Optimizations

[](#performance-optimizations)

- ✅ **Field Limits**: Maximum 25 fields per embed
- ✅ **Efficient Processing**: Optimized data extraction
- ✅ **Memory Tracking**: Built-in memory usage monitoring
- ✅ **Non-blocking**: Asynchronous HTTP requests
- ✅ **Smart Formatting**: Automatic data type handling

### Rate Limiting Considerations

[](#rate-limiting-considerations)

Discord webhooks have rate limits:

- **5 requests per 2 seconds** per webhook
- **30 requests per minute** per webhook

For high-traffic applications, consider:

- Using higher log levels in production
- Implementing custom rate limiting
- Using multiple webhooks for different log levels

🔧 Troubleshooting
-----------------

[](#-troubleshooting)

### Installation Issues

[](#installation-issues)

```
# Regenerate autoload files
composer dump-autoload

# Discover packages
php artisan package:discover

# Clear configuration cache
php artisan config:clear
```

### Configuration Issues

[](#configuration-issues)

```
# Check package status
php artisan logger:discord-status

# Test configuration
php artisan logger:discord-test --level=error
```

### Webhook Issues

[](#webhook-issues)

- ✅ Verify webhook URL format and validity
- ✅ Check Discord server permissions
- ✅ Test connectivity: `php artisan logger:discord-status`
- ✅ Verify webhook hasn't been deleted or regenerated

### Logs Not Appearing

[](#logs-not-appearing)

- ✅ Check environment configuration matches current env
- ✅ Verify log level settings (debug &lt; info &lt; warning &lt; error)
- ✅ Run comprehensive diagnosis: `php artisan logger:discord-status`
- ✅ Check Discord channel for rate limiting messages

### Performance Issues

[](#performance-issues)

- ✅ Reduce log level in production (use `error` instead of `debug`)
- ✅ Disable context in high-traffic environments
- ✅ Implement application-level rate limiting
- ✅ Monitor memory usage with built-in tracking

📋 Example Discord Message
-------------------------

[](#-example-discord-message)

Here's what your logs will look like in Discord:

[![demo-error-imessage](./.github/error-log.png)](./.github/error-log.png)[![demo-info-imessage](./.github/info-log.png)](./.github/info-log.png)[![demo-warning-imessage](./.github/warning-log.png)](./.github/warning-log.png)

📄 License
---------

[](#-license)

MIT License. See [LICENSE.md](LICENSE.md) for details.

**Made with ❤️ for the Laravel community**

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance64

Regular maintenance activity

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% 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 ~16 days

Total

4

Last Release

221d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1d91b34580acaf157dcf573358d94ce8b1049ca015611dfc3e7ca85033d4161a?d=identicon)[okriiza](/maintainers/okriiza)

---

Top Contributors

[![okriiza](https://avatars.githubusercontent.com/u/53373181?v=4)](https://github.com/okriiza "okriiza (5 commits)")[![fauzanpurwaw](https://avatars.githubusercontent.com/u/119583159?v=4)](https://github.com/fauzanpurwaw "fauzanpurwaw (2 commits)")

---

Tags

laravel-debuglaravel-discord-channellaravel-loggerlaravel-packagelaravelloggingloggerdiscord

### Embed Badge

![Health badge](/badges/renslabs-laravel-logger-discord-channel/health.svg)

```
[![Health](https://phpackages.com/badges/renslabs-laravel-logger-discord-channel/health.svg)](https://phpackages.com/packages/renslabs-laravel-logger-discord-channel)
```

###  Alternatives

[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)[kabbouchi/laravel-logger-discord-channel

A Discord based Monolog driver for Laravel

149.5k](/packages/kabbouchi-laravel-logger-discord-channel)[yzen.dev/mono-processor

This Processor will display in the logs bread crumbs by which you can more quickly and accurately identify the cause of the error.

116.1k](/packages/yzendev-mono-processor)

PHPackages © 2026

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