PHPackages                             onamfc/laravel-devlogger - 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. [Database &amp; ORM](/categories/database)
4. /
5. onamfc/laravel-devlogger

ActiveLibrary[Database &amp; ORM](/categories/database)

onamfc/laravel-devlogger
========================

A custom logging package for Laravel with database storage and automatic error catching

1.1.9(10mo ago)173011MITPHPPHP ^8.2

Since Jul 8Pushed 9mo agoCompare

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

READMEChangelog (10)Dependencies (5)Versions (11)Used By (1)

[![](https://camo.githubusercontent.com/b31791a149e63a6e7066ad0f6bc3928117c1d01b295da2779031665c44705b62/68747470733a2f2f647074336171657966707468352e636c6f756466726f6e742e6e65742f6465766c6f676765722f696d672f6465766c6f676765722d6c6f676f2d692d2d6461726b2e706e67)](https://camo.githubusercontent.com/b31791a149e63a6e7066ad0f6bc3928117c1d01b295da2779031665c44705b62/68747470733a2f2f647074336171657966707468352e636c6f756466726f6e742e6e65742f6465766c6f676765722f696d672f6465766c6f676765722d6c6f676f2d692d2d6461726b2e706e67)
=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#)

 **A comprehensive logging package for Laravel that stores logs in a database with automatic error catching, advanced filtering, and management capabilities.**

Features
--------

[](#features)

- **Database Logging**: Store logs in database with rich metadata
- **Automatic Error Catching**: Automatically capture and log all application exceptions
- **Tagging System**: Organize logs with custom tags
- **Advanced Filtering**: Filter logs by level, date, queue, status, and more
- **Automatic Cleanup**: Configurable log retention with automatic cleanup
- **Queue Support**: Associate logs with specific queues
- **Request Context**: Capture HTTP request information automatically
- **User Tracking**: Track which user triggered each log entry
- **Flexible Configuration**: Extensive configuration options via environment variables

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

[](#installation)

### 1. Install via Composer

[](#1-install-via-composer)

```
composer require onamfc/laravel-devlogger
```

### 2. Publish Configuration and Migrations

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

```
# Publish configuration file
php artisan vendor:publish --tag=devlogger-config

# Publish migrations (optional - they auto-load by default)
php artisan vendor:publish --tag=devlogger-migrations
```

### 3. Run Migrations

[](#3-run-migrations)

```
php artisan migrate
```

### 4. Configure Environment Variables (Optional)

[](#4-configure-environment-variables-optional)

Add these to your `.env` file to customize behavior:

```
# Enable/disable database logging
DEVLOGGER_ENABLE_DB=true

# Default log level
DEVLOGGER_LOG_LEVEL=debug

# Database connection (null = default)
DEVLOGGER_DB_CONNECTION=null

# Table name
DEVLOGGER_TABLE_NAME=developer_logs

# Auto-catch exceptions
DEVLOGGER_AUTO_CATCH=true

# Log retention (days)
DEVLOGGER_RETENTION_DAYS=30

# Fallback Laravel log channels
DEVLOGGER_FALLBACK_CHANNELS=null
```

Basic Usage
-----------

[](#basic-usage)

### Manual Logging

[](#manual-logging)

```
use DevLogger;

// Basic logging
DevLogger::info('User logged in', ['user_id' => 123]);
DevLogger::error('Payment failed', ['order_id' => 456, 'error' => 'Card declined']);
DevLogger::debug('Debug information', ['data' => $debugData]);

// With queue context
DevLogger::onQueue('email-queue')->info('Email sent', ['recipient' => 'user@example.com']);

// With tags
DevLogger::withTags(['payment', 'critical'])->error('Payment gateway timeout');

// Method chaining
DevLogger::onQueue('reports')
    ->withTags(['report', 'daily'])
    ->info('Daily report generated');
```

### Exception Logging

[](#exception-logging)

```
try {
    // Some risky operation
    $result = $this->riskyOperation();
} catch (Exception $e) {
    DevLogger::logException($e, ['context' => 'additional info']);
    throw $e; // Re-throw if needed
}
```

### Automatic Exception Catching - Laravel 9, 10, 11

[](#automatic-exception-catching---laravel-9-10-11)

The package automatically catches and logs all unhandled exceptions when `DEVLOGGER_AUTO_CATCH=true` (default). To set this up:

#### Option 1: Extend the DevLogger Exception Handler

[](#option-1-extend-the-devlogger-exception-handler)

In your `app/Exceptions/Handler.php`:

```
