PHPackages                             yoeriboven/laravel-log-db - 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. yoeriboven/laravel-log-db

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

yoeriboven/laravel-log-db
=========================

A database driver for logging with Laravel

3.0(3mo ago)59175.5k↓33.5%15[2 PRs](https://github.com/yoeriboven/laravel-log-db/pulls)MITPHPPHP ^8.2|^8.3|^8.4|^8.5CI passing

Since May 18Pushed 1w ago3 watchersCompare

[ Source](https://github.com/yoeriboven/laravel-log-db)[ Packagist](https://packagist.org/packages/yoeriboven/laravel-log-db)[ Docs](https://github.com/yoeriboven/laravel-log-db)[ RSS](/packages/yoeriboven-laravel-log-db/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (14)Versions (18)Used By (0)

[![](https://camo.githubusercontent.com/2bedf63f24cda7efab02da955dc11fb7ef8a060e2f26b73c33a7aac84529b8a3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f737570706f72742d756b7261696e652e7376673f743d31)](https://supportukrainenow.org)

Laravel Database Logger
=======================

[](#laravel-database-logger)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4c7b7e5036b5d19c2d8c4e503dee582699dc5eee12c5b761b356bae76f0b5c23/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796f657269626f76656e2f6c61726176656c2d6c6f672d64622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yoeriboven/laravel-log-db)[![GitHub Tests Action Status](https://github.com/yoeriboven/laravel-log-db/actions/workflows/run-tests.yml/badge.svg)](https://github.com/yoeriboven/laravel-log-db/actions/workflows/run-tests.yml)[![GitHub Code Style Action Status](https://github.com/yoeriboven/laravel-log-db/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/yoeriboven/laravel-log-db/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/7cdb0d6efbcf5b4ff151a0665e7a7d5a3a56519bd05c2db41bb5f0d88485a0d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796f657269626f76656e2f6c61726176656c2d6c6f672d64622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/yoeriboven/laravel-log-db)

This package provides a custom log driver for storing Laravel log messages in the database.

Compatible with Laravel 12 and 13.

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

Log::channel('db')->info('Your message');
```

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

[](#installation)

Install the package via Composer:

```
composer require yoeriboven/laravel-log-db
```

Publish and run the migrations:

```
php artisan vendor:publish --tag="log-db-migrations"
php artisan migrate
```

Next, configure the database channel in `config/logging.php`:

```
use Yoeriboven\LaravelLogDb\DatabaseLogger;

return [
    'channels' => [
        'db' => [
            'driver'     => 'custom',
            'via'        => DatabaseLogger::class,
            'connection' => env('LOG_DB_CONNECTION'), // Optional, defaults to app's DB connection
            'days'       => 7, // Optional, retention period in days
            'level'      => env('LOG_LEVEL', 'debug'), // Optional
        ],
    ]
]
```

Usage
-----

[](#usage)

To use the database channel, either:

- Add it to the stack channel for combined logging:

```
// config/logging.php
return [
    'channels' => [
        'stack' => [
            'channels' => ['single', 'db'],
        ],
        // other channels
    ]
]
```

- Log directly to the database:

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

Log::channel('db')->info('Your log message');
```

### Fallback channel

[](#fallback-channel)

If the database is unavailable, you can define a fallback channel to handle logs:

```
// config/logging.php

return [
    'channels' => [
        'fallback' => [
            'channels' => ['single'],
        ],
    ]
]
```

If no fallback channel is defined it will default to the `single` channel.

### Pruning the logs

[](#pruning-the-logs)

To automatically delete logs older than a specified number of days, set the `days` key in the configuration and schedule log pruning:

```
$schedule->command('model:prune', [
    '--model' => [
        \Yoeriboven\LaravelLogDb\Models\LogMessage::class,
    ],
])->daily();
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Yoeri Boven](https://twitter.com/yoeriboven)

License
-------

[](#license)

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

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance90

Actively maintained with recent releases

Popularity48

Moderate usage in the ecosystem

Community19

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 74.6% 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 ~127 days

Total

12

Last Release

107d ago

Major Versions

1.4 → 2.02025-02-14

2.1 → 3.02026-03-18

PHP version history (4 changes)1.0PHP ^8.1

1.4PHP ^8.1|^8.2|^8.3

2.0PHP ^8.1|^8.2|^8.3|8.4

3.0PHP ^8.2|^8.3|^8.4|^8.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4047804?v=4)[Yoeri Boven](/maintainers/yoeriboven)[@yoeriboven](https://github.com/yoeriboven)

---

Top Contributors

[![yoeriboven](https://avatars.githubusercontent.com/u/4047804?v=4)](https://github.com/yoeriboven "yoeriboven (94 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (15 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (12 commits)")[![victayo](https://avatars.githubusercontent.com/u/15233960?v=4)](https://github.com/victayo "victayo (2 commits)")[![edwinvdpol](https://avatars.githubusercontent.com/u/9265514?v=4)](https://github.com/edwinvdpol "edwinvdpol (1 commits)")[![ComeCaramelos](https://avatars.githubusercontent.com/u/32031130?v=4)](https://github.com/ComeCaramelos "ComeCaramelos (1 commits)")[![alexkart](https://avatars.githubusercontent.com/u/8249105?v=4)](https://github.com/alexkart "alexkart (1 commits)")

---

Tags

laravelyoeribovenlaravel-log-db

###  Code Quality

TestsPest

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/yoeriboven-laravel-log-db/health.svg)

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

###  Alternatives

[spatie/laravel-responsecache

Speed up a Laravel application by caching the entire response

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

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[keepsuit/laravel-opentelemetry

OpenTelemetry integration for laravel

167558.4k1](/packages/keepsuit-laravel-opentelemetry)[sunchayn/nimbus

A Laravel package providing an in-browser API client with automatic schema generation, live validation, and built-in authentication with a touch of Laravel-tailored magic for effortless API testing.

32041.3k](/packages/sunchayn-nimbus)[spatie/laravel-error-share

Share your Laravel errors to Flare

431.4M6](/packages/spatie-laravel-error-share)[tapp/filament-maillog

Filament plugin to view outgoing mail

3070.3k1](/packages/tapp-filament-maillog)

PHPackages © 2026

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