PHPackages                             arseno25/exception-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. arseno25/exception-logger

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

arseno25/exception-logger
=========================

This is my package exception-logger

1.0.0(7mo ago)00[3 PRs](https://github.com/Arseno25/filament-exception-logger/pulls)MITPHPPHP ^8.2CI passing

Since Nov 21Pushed 1w agoCompare

[ Source](https://github.com/Arseno25/filament-exception-logger)[ Packagist](https://packagist.org/packages/arseno25/exception-logger)[ Docs](https://github.com/arseno25/exception-logger)[ GitHub Sponsors](https://github.com/Arseno25)[ RSS](/packages/arseno25-exception-logger/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (16)Versions (7)Used By (0)

Exception Logger for Laravel Filament
=====================================

[](#exception-logger-for-laravel-filament)

Log your Laravel exceptions into a database and manage them from a beautiful Filament admin interface.

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

[](#-features)

- **Database Exception Logging** - Automatically logs all exceptions with full context
- **Critical Detection** - Intelligent classification of critical exceptions
- **Multi-Channel Notifications** - Send alerts via Telegram, Slack, Discord, or Email
- **Filament Admin Interface** - Complete exception management with dashboard widget
- **AI-Powered Analysis** - Optional AI solution analysis for error resolution
- **Team Collaboration** - Comment system with user mentions
- **Automatic Pruning** - Configurable log retention policies

📋 Requirements
--------------

[](#-requirements)

- PHP 8.2+
- Laravel 11.0+ or 12.0+
- Filament 4.0+

🚀 Installation
--------------

[](#-installation)

### 1. Install the package

[](#1-install-the-package)

```
composer require arseno25/exception-logger
```

### 2. Publish and run migrations

[](#2-publish-and-run-migrations)

```
php artisan vendor:publish --tag="exception-logger-migrations"
php artisan migrate
```

### 3. Publish configuration

[](#3-publish-configuration)

```
php artisan vendor:publish --tag="exception-logger-config"
```

### 4. Configure logging channel

[](#4-configure-logging-channel)

Add to `config/logging.php`:

```
use Arseno25\ExceptionLogger\Logging\DatabaseLoggerHandler;

'channels' => [
    // ...
    'exception_logger' => [
        'driver' => 'monolog',
        'level' => 'error',
        'handler' => DatabaseLoggerHandler::class,
    ],
],
```

Add to your default stack:

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

### 5. Add to Filament panel

[](#5-add-to-filament-panel)

Register in `app/Providers/Filament/AdminPanelProvider.php`:

```
use Arseno25\ExceptionLogger\ExceptionLoggerPlugin;

->plugins([
    ExceptionLoggerPlugin::make(),
])
```

This will automatically register:

- **Exception Logs** resource page for managing exceptions
- **Exception Stats Overview** widget showing 7-day error trends

### 6. Access Exception Management

[](#6-access-exception-management)

After installation:

1. Navigate to **Exception Logs** in your Filament admin panel
2. View the **Exception Stats Overview** widget on your dashboard
3. Configure widget permissions and visibility as needed

🚨 Critical Exception Detection
------------------------------

[](#-critical-exception-detection)

Automatically detects critical exceptions based on:

- **Exception classes** - QueryException, PDOException, HttpException, etc.
- **Message keywords** - database, connection, timeout, memory, fatal, etc.
- **HTTP status codes** - 5xx errors

Configure in `config/exception-logger.php`:

```
'critical' => [
    'exceptions' => [
        \Illuminate\Database\QueryException::class,
        \PDOException::class,
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
    ],
    'keywords' => [
        'database', 'connection', 'timeout', 'memory', 'fatal',
    ],
],
```

📢 Notifications
---------------

[](#-notifications)

Configure notifications in `config/exception-logger.php`:

### Telegram

[](#telegram)

```
'telegram' => [
    'enabled' => env('EXCEPTION_LOGGER_TELEGRAM_ENABLED', false),
    'token' => env('TELEGRAM_BOT_TOKEN'),
    'chat_id' => env('TELEGRAM_CHAT_ID'),
    'throttle_minutes' => 5,
],
```

```
EXCEPTION_LOGGER_TELEGRAM_ENABLED=true
TELEGRAM_BOT_TOKEN=123456:ABCDEF123456789
TELEGRAM_CHAT_ID=-1001234567890
```

### Slack

[](#slack)

```
'slack' => [
    'enabled' => env('EXCEPTION_LOGGER_SLACK_ENABLED', false),
    'webhook_url' => env('EXCEPTION_LOGGER_SLACK_WEBHOOK_URL'),
    'channel' => env('EXCEPTION_LOGGER_SLACK_CHANNEL', '#exceptions'),
    'username' => env('EXCEPTION_LOGGER_SLACK_USERNAME', 'Exception Logger'),
    'throttle_minutes' => 5,
],
```

```
EXCEPTION_LOGGER_SLACK_ENABLED=true
EXCEPTION_LOGGER_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
EXCEPTION_LOGGER_SLACK_CHANNEL=#exceptions
```

### Discord

[](#discord)

```
'discord' => [
    'enabled' => env('EXCEPTION_LOGGER_DISCORD_ENABLED', false),
    'webhook_url' => env('EXCEPTION_LOGGER_DISCORD_WEBHOOK_URL'),
    'username' => env('EXCEPTION_LOGGER_DISCORD_USERNAME', 'Exception Logger'),
    'throttle_minutes' => 5,
],
```

```
EXCEPTION_LOGGER_DISCORD_ENABLED=true
EXCEPTION_LOGGER_DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR/WEBHOOK/URL
```

### Email

[](#email)

```
'email' => [
    'enabled' => env('EXCEPTION_LOGGER_EMAIL_ENABLED', false),
    'to' => env('EXCEPTION_LOGGER_EMAIL_TO'),
    'from' => [
        'address' => env('EXCEPTION_LOGGER_EMAIL_FROM_ADDRESS', env('MAIL_FROM_ADDRESS')),
        'name' => env('EXCEPTION_LOGGER_EMAIL_FROM_NAME', 'Exception Logger'),
    ],
    'subject_prefix' => env('EXCEPTION_LOGGER_EMAIL_SUBJECT_PREFIX', '[Exception Alert]'),
    'throttle_minutes' => 5,
],
```

```
EXCEPTION_LOGGER_EMAIL_ENABLED=true
EXCEPTION_LOGGER_EMAIL_TO=admin@example.com,dev@example.com
EXCEPTION_LOGGER_EMAIL_FROM_ADDRESS=noreply@example.com
```

🤖 AI Solution Analysis
----------------------

[](#-ai-solution-analysis)

Optional AI-powered error analysis:

```
'ai' => [
    'enabled' => env('EXCEPTION_LOGGER_AI_ENABLED', false),
    'api_key' => env('EXCEPTION_LOGGER_AI_API_KEY'),
    'base_url' => env('EXCEPTION_LOGGER_AI_BASE_URL', 'https://api.openai.com/v1'),
    'model' => env('EXCEPTION_LOGGER_AI_MODEL', 'gpt-3.5-turbo'),
    'temperature' => 0.5,
],
```

```
EXCEPTION_LOGGER_AI_ENABLED=true
EXCEPTION_LOGGER_AI_API_KEY=sk-your-api-key
EXCEPTION_LOGGER_AI_MODEL=gpt-3.5-turbo
```

📊 Custom Widget Usage
---------------------

[](#-custom-widget-usage)

### Adding Widget to Custom Dashboard

[](#adding-widget-to-custom-dashboard)

If you want to add the exception stats widget to a specific Filament dashboard:

```
use Arseno25\ExceptionLogger\Widgets\ExceptionStatsOverview;

class MyCustomDashboard extends Filament\Pages\Dashboard
{
    protected function getHeaderWidgets(): array
    {
        return [
            ExceptionStatsOverview::class,
        ];
    }
}
```

### Creating Custom Exception Widget

[](#creating-custom-exception-widget)

You can extend the base widget for custom functionality:

```
