PHPackages                             haythem-bekir/laravel-log-metrics - 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-log-metrics

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

haythem-bekir/laravel-log-metrics
=================================

Laravel package for sending comprehensive log metrics and statistics reports to Discord webhooks with daily summaries and insights

v1.0.0(5mo ago)032MITPHPPHP ^8.1

Since Jan 15Pushed 5mo agoCompare

[ Source](https://github.com/maisonduweb-agency/laravel-log-metrics)[ Packagist](https://packagist.org/packages/haythem-bekir/laravel-log-metrics)[ RSS](/packages/haythem-bekir-laravel-log-metrics/feed)WikiDiscussions main Synced today

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

Laravel Log Metrics
===================

[](#laravel-log-metrics)

[![Latest Version on Packagist](https://camo.githubusercontent.com/f0300967e7292c858a6de447ba81d58eff1e3bbfff9f0941506658882fe9f86c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6861797468656d2d62656b69722f6c61726176656c2d6c6f672d6d6574726963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haythem-bekir/laravel-log-metrics)[![Total Downloads](https://camo.githubusercontent.com/950558d4592d68f958468eecd8242084ce7d970e403b6de089982bf1830aabf9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6861797468656d2d62656b69722f6c61726176656c2d6c6f672d6d6574726963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haythem-bekir/laravel-log-metrics)[![License](https://camo.githubusercontent.com/39bfaad13c9d4feea3a0d521a6760c746ae1cd0dc0b722c5d6c7b8a6d47af053/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6861797468656d2d62656b69722f6c61726176656c2d6c6f672d6d6574726963732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/haythem-bekir/laravel-log-metrics)

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 or higher
- Laravel 10.x, 11.x, or 12.x

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

[](#installation)

You can install the package via Composer:

```
composer require haythem-bekir/laravel-log-metrics
```

Publish the configuration file:

```
php artisan vendor:publish --tag=log-metrics-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:

```
LOG_METRICS_DAILY_REPORT_ENABLED=true
LOG_METRICS_DAILY_REPORT_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_URL
LOG_METRICS_DAILY_REPORT_TIME=08:00
LOG_METRICS_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('log-metrics:daily-report')->dailyAt('08:00');
```

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

```
protected function schedule(Schedule $schedule): void
{
    $schedule->command('log-metrics: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 log-metrics:daily-report

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

# Preview without sending (dry run)
php artisan log-metrics: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/log-metrics.php`:

```
return [
    'daily_report' => [
        'enabled' => env('LOG_METRICS_DAILY_REPORT_ENABLED', false),
        'webhook_url' => env('LOG_METRICS_DAILY_REPORT_WEBHOOK_URL'),
        'time' => env('LOG_METRICS_DAILY_REPORT_TIME', '08:00'),
        'timezone' => env('LOG_METRICS_DAILY_REPORT_TIMEZONE', 'UTC'),
    ],

    'appearance' => [
        'username' => env('LOG_METRICS_BOT_USERNAME', 'Laravel Logger'),
        'avatar_url' => env('LOG_METRICS_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('LOG_METRICS_ENVIRONMENT_LABEL', env('APP_ENV')),

    'log_viewer' => [
        'enabled' => env('LOG_METRICS_LOG_VIEWER_ENABLED', true),
        'app_url' => env('LOG_METRICS_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
LOG_METRICS_LOG_VIEWER_ENABLED=true

# Override app URL if needed
LOG_METRICS_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 Log Metrics

```

> 💡 **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)

Support
-------

[](#support)

If you find this package helpful, please consider starring it on [GitHub](https://github.com/maisonduweb-agency/laravel-log-metrics)!

License
-------

[](#license)

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

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance70

Regular maintenance activity

Popularity7

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

171d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/65097028?v=4)[haythembekir](/maintainers/haythembekir)[@haythembekir](https://github.com/haythembekir)

---

Top Contributors

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

---

Tags

laravelloggingmonitoringMetricswebhookstatisticsdiscord

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.9k3](/packages/defstudio-telegraph)[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

2.8k9.0M69](/packages/spatie-laravel-responsecache)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.0k](/packages/simplestats-io-laravel-client)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1563.2k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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