PHPackages                             haythem-bekir/laravel-discord-logger - 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. haythem-bekir/laravel-discord-logger

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

haythem-bekir/laravel-discord-logger
====================================

Laravel package for sending log notifications to Discord via webhooks with real-time alerts and daily reports

v1.0.0(3mo ago)17MITPHPPHP ^8.1CI failing

Since Jan 14Pushed 3mo agoCompare

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

READMEChangelogDependencies (9)Versions (2)Used By (0)

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

[](#laravel-discord-logger)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6ba6a6e997f0233ab8070c8349e1c7ccc805a1ebacc94260601427f341f04088/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6861797468656d2d62656b69722f6c61726176656c2d646973636f72642d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haythem-bekir/laravel-discord-logger)[![Total Downloads](https://camo.githubusercontent.com/3ace775ded10bc2d29534a074f86159c69f9e39b22b787eec8fec83baf12771e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6861797468656d2d62656b69722f6c61726176656c2d646973636f72642d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haythem-bekir/laravel-discord-logger)[![License](https://camo.githubusercontent.com/01f86e687fec4fd5257653a1aca45c2e30eb794099ab133ab01b9000e87665c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6861797468656d2d62656b69722f6c61726176656c2d646973636f72642d6c6f676765722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haythem-bekir/laravel-discord-logger)

A Laravel package that sends **daily log statistics reports** to Discord. Get comprehensive insights about your application's logs delivered to your Discord channel every day.

Why Daily Reports?
------------------

[](#why-daily-reports)

Instead of alert fatigue from real-time notifications, this package provides:

- 📊 **Comprehensive daily statistics** - Total logs, breakdown by level and channel
- ⚠️ **Top recurring errors** - Identify patterns and prioritize fixes
- 🎯 **Better signal-to-noise** - Review at your chosen time, not during incidents
- 🚀 **Zero performance impact** - Runs as a scheduled task, not on every request
- 📈 **Historical insights** - See trends and patterns over time

Features
--------

[](#features)

- ✅ Daily log statistics report sent to Discord
- ✅ Breakdown by log level (emergency, alert, critical, error, warning, etc.)
- ✅ Breakdown by channel
- ✅ Top 5 recurring errors with count
- ✅ Customizable bot appearance (username, avatar)
- ✅ Environment labels (production, staging, etc.)
- ✅ Manual or scheduled execution
- ✅ Dry-run mode for previewing reports
- ✅ Clean SOLID architecture
- ✅ Fully testable

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10.x, 11.x, or 12.x

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

[](#installation)

Install via Composer:

```
composer require haythem-bekir/laravel-discord-logger
```

Publish the configuration file:

```
php artisan vendor:publish --tag=discord-logger-config
```

Quick Start
-----------

[](#quick-start)

### 1. Get Your Discord Webhook URL

[](#1-get-your-discord-webhook-url)

1. Go to your Discord server settings
2. Navigate to **Integrations** → **Webhooks**
3. Click **New Webhook**
4. Choose the channel for reports
5. Copy the webhook URL

### 2. Configure Your Environment

[](#2-configure-your-environment)

Add to your `.env` file:

```
DISCORD_LOGGER_DAILY_REPORT_ENABLED=true
DISCORD_LOGGER_DAILY_REPORT_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_URL
DISCORD_LOGGER_DAILY_REPORT_TIME=08:00
DISCORD_LOGGER_DAILY_REPORT_TIMEZONE=UTC
```

### 3. Schedule the Daily Report

[](#3-schedule-the-daily-report)

**Laravel 11+ (`routes/console.php`):**

```
use Illuminate\Support\Facades\Schedule;

Schedule::command('discord-logger:daily-report')->dailyAt('08:00');
```

**Laravel 10 (`app/Console/Kernel.php`):**

```
protected function schedule(Schedule $schedule): void
{
    $schedule->command('discord-logger:daily-report')->dailyAt('08:00');
}
```

Make sure your scheduler is running:

```
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
```

That's it! You'll receive daily reports at 8:00 AM (UTC).

Usage
-----

[](#usage)

### Manual Execution

[](#manual-execution)

Run reports manually anytime:

```
# Send yesterday's report
php artisan discord-logger:daily-report

# Send report for a specific date
php artisan discord-logger:daily-report --date=2024-01-15

# Preview without sending (dry run)
php artisan discord-logger:daily-report --dry-run
```

### Programmatic Usage

[](#programmatic-usage)

Use the actions directly in your code:

```
use HaythemBekir\DiscordLogger\Application\DailyReport\GatherLogStatisticsAction;
use HaythemBekir\DiscordLogger\Application\DailyReport\BuildDailyReportAction;
use HaythemBekir\DiscordLogger\Application\DailyReport\SendDailyReportAction;
use Carbon\Carbon;

class CustomReportService
{
    public function __construct(
        private GatherLogStatisticsAction $gather,
        private BuildDailyReportAction $build,
        private SendDailyReportAction $send,
    ) {}

    public function sendWeeklyDigest(): void
    {
        $dates = collect(range(0, 6))->map(fn($days) => Carbon::now()->subDays($days));

        foreach ($dates as $date) {
            $stats = $this->gather->execute($date);
            $report = $this->build->execute($stats);
            $this->send->execute($report);
        }
    }
}
```

Configuration
-------------

[](#configuration)

The package provides several customization options in `config/discord-logger.php`:

```
return [
    'daily_report' => [
        'enabled' => env('DISCORD_LOGGER_DAILY_REPORT_ENABLED', false),
        'webhook_url' => env('DISCORD_LOGGER_DAILY_REPORT_WEBHOOK_URL'),
        'time' => env('DISCORD_LOGGER_DAILY_REPORT_TIME', '08:00'),
        'timezone' => env('DISCORD_LOGGER_DAILY_REPORT_TIMEZONE', 'UTC'),
    ],

    'appearance' => [
        'username' => env('DISCORD_LOGGER_BOT_USERNAME', 'Laravel Logger'),
        'avatar_url' => env('DISCORD_LOGGER_BOT_AVATAR_URL'),
    ],

    'colors' => [
        'emergency' => 0xFF0000, // Red
        'alert'     => 0xFF3300, // Orange-Red
        'critical'  => 0xFF6600, // Orange
        'error'     => 0xFF9900, // Dark Orange
        'warning'   => 0xFFCC00, // Yellow
        'notice'    => 0x00CCFF, // Cyan
        'info'      => 0x0099FF, // Blue
        'debug'     => 0x999999, // Gray
    ],

    'environment_label' => env('DISCORD_LOGGER_ENVIRONMENT_LABEL', env('APP_ENV')),

    'log_viewer' => [
        'enabled' => env('DISCORD_LOGGER_LOG_VIEWER_ENABLED', true),
        'app_url' => env('DISCORD_LOGGER_APP_URL', env('APP_URL')),
    ],
];
```

Log Viewer Integration
----------------------

[](#log-viewer-integration)

If you have a Laravel Log Viewer package installed, error messages in Discord reports will automatically become **clickable links** that take you directly to the log viewer!

### Supported Log Viewers

[](#supported-log-viewers)

- **[opcodesio/log-viewer](https://github.com/opcodesio/log-viewer)** - Modern, feature-rich log viewer (Recommended)
- **[rap2hpoutre/laravel-log-viewer](https://github.com/rap2hpoutre/laravel-log-viewer)** - Simple, lightweight log viewer

### How It Works

[](#how-it-works)

1. Install any supported log viewer package:

    ```
    composer require opcodesio/log-viewer
    ```
2. Ensure your `APP_URL` is configured in `.env`:

    ```
    APP_URL=https://your-app.com
    ```
3. Error messages in Discord will automatically become clickable:

    ```
    Top Recurring Errors:
      • 8x: [foreach() argument must be of type array|object, null given](https://your-app.com/log-viewer?query=foreach)
      • 6x: [syntax error, unexpected token "return"](https://your-app.com/log-viewer?query=syntax+error)

    ```

Clicking the error takes you directly to the log viewer with a search query pre-filled, making it easy to investigate issues!

### Configuration

[](#configuration-1)

You can customize the log viewer integration:

```
# Enable/disable log viewer links
DISCORD_LOGGER_LOG_VIEWER_ENABLED=true

# Override app URL if needed
DISCORD_LOGGER_APP_URL=https://your-app.com
```

What the Report Includes
------------------------

[](#what-the-report-includes)

Each daily report contains:

- **📅 Date** - Which day the report covers
- **📊 Total Logs** - Total number of log entries
- **📈 Breakdown by Level** - Count for each level with emoji indicators:
    - 🚨 Emergency
    - 🔔 Alert
    - 💥 Critical
    - ❌ Error
    - ⚠️ Warning
    - 📝 Notice
    - ℹ️ Info
    - 🔍 Debug
- **📁 Breakdown by Channel** - Count per logging channel
- **⚠️ Top Recurring Errors** - Top 5 most frequent error messages

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

[](#example-discord-message)

```
📅 Daily Log Report - 2024-01-15

Issues detected in the last 24 hours.

Total Logs: 1,234
❌ Error: 15
⚠️ Warning: 47
📝 Notice: 122
ℹ️ Info: 1,050

By Channel:
  production: 1,234

Top Recurring Errors:
  • 8x: foreach() argument must be of type array|object, null given [View in Log Viewer]
  • 6x: syntax error, unexpected token "return" [View in Log Viewer]
  • 2x: Call to undefined method [View in Log Viewer]

Generated by Laravel Discord Logger

```

> 💡 **Note:** If you have a Log Viewer package installed, the error messages become clickable links!

Testing
-------

[](#testing)

```
# Run tests
composer test

# Run with coverage
composer test-coverage

# Static analysis
composer analyse

# Code style check
composer format-check

# Auto-fix code style
composer format
```

Architecture
------------

[](#architecture)

This package follows **SOLID principles** and **Domain-Driven Design**:

```
src/
├── Application/DailyReport/      # Use cases & DTOs
│   ├── GatherLogStatisticsAction.php
│   ├── BuildDailyReportAction.php
│   └── SendDailyReportAction.php
├── Domain/                        # Business logic & value objects
│   ├── Config/
│   └── ValueObjects/
├── Infrastructure/                # External integrations
│   └── Http/DiscordWebhookClient.php
└── Console/Commands/              # Artisan commands

```

This makes the package:

- ✅ Testable - Mock dependencies easily
- ✅ Extensible - Implement custom transports
- ✅ Maintainable - Clear separation of concerns

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Upgrading
---------

[](#upgrading)

Please see [UPGRADE](UPGRADE.md) for upgrade instructions.

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

Credits
-------

[](#credits)

- [Haythem Bekir](https://github.com/haythembekir20)
- Built with [Spatie Laravel Package Tools](https://github.com/spatie/laravel-package-tools)

License
-------

[](#license)

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

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance78

Regular maintenance activity

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

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

Unknown

Total

1

Last Release

118d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd513ce03910ad1ce427fd6eb8e6ab278286bf64d4380d5889d70bd1b8021c07?d=identicon)[haythembekir](/maintainers/haythembekir)

---

Top Contributors

[![Haythem-mdw2022](https://avatars.githubusercontent.com/u/137274981?v=4)](https://github.com/Haythem-mdw2022 "Haythem-mdw2022 (5 commits)")

---

Tags

laravelloggingnotificationswebhookmonologdiscord

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[marvinlabs/laravel-discord-logger

Logging to a discord channel in Laravel

2081.1M2](/packages/marvinlabs-laravel-discord-logger)[naoray/laravel-github-monolog

Log driver to store logs as github issues

10619.4k](/packages/naoray-laravel-github-monolog)[lefuturiste/monolog-discord-handler

A simple monolog handler for support Discord webhooks

34111.6k4](/packages/lefuturiste-monolog-discord-handler)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)

PHPackages © 2026

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