PHPackages                             faanigee/dblogger - 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. faanigee/dblogger

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

faanigee/dblogger
=================

Generate Logs for BK Accounts Module

032PHP

Since May 20Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/faanigee/db-logger)[ Packagist](https://packagist.org/packages/faanigee/dblogger)[ RSS](/packages/faanigee-dblogger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

DbLogger Package for Laravel
============================

[](#dblogger-package-for-laravel)

A powerful and flexible database logging package for Laravel applications that supports batch logging, queued operations, and context enrichment.

Features
--------

[](#features)

- Simple integration with Laravel applications
- Database-backed persistent logging
- Support for all standard log levels
- Request context logging
- User tracking
- Batch logging support
- Asynchronous (queued) logging
- Context enrichment
- Configurable retention policies
- Log viewer interface

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

[](#requirements)

- PHP &gt;= 8.1
- Laravel &gt;= 10.0
- Database support (MySQL, PostgreSQL, etc.)
- Redis (optional, for queue support)

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

[](#installation)

1. Install the package via Composer:

```
composer require faanigee/dblogger
```

2. Publish the configuration file:

```
php artisan vendor:publish --provider="Faanigee\DbLogger\DbLoggerServiceProvider" --tag="config"
```

Publish the views (optional):
-----------------------------

[](#publish-the-views-optional)

```
php artisan vendor:publish --provider="Faanigee\DbLogger\DbLoggerServiceProvider" --tag="views"
```

Enviroment Variables
--------------------

[](#enviroment-variables)

```
DB_LOGGER_CONNECTION=log_db
DB_LOGGER_HOST=mariadb
DB_LOGGER_PORT=3306
DB_LOGGER_DATABASE=accounts_logs
DB_LOGGER_USERNAME=root
DB_LOGGER_PASSWORD=
LOG_LEVEL=debug

DB_LOGGER_RETENTION_DAYS=30
DB_LOGGER_BATCH_SIZE=100
DB_LOGGER_BATCH_TIMEOUT=120
DB_LOGGER_QUEUE_NAME=db_logger
DB_LOGGER_QUEUE_CONNECTION=radis
DB_LOGGER_STYLE=light
```

Add connection for database in config/database.php if Database connection error occured (Optional)
--------------------------------------------------------------------------------------------------

[](#add-connection-for-database-in-configdatabasephp-if-database-connection-error-occured-optional)

```
'connections' => [
	'log_db' => [
		'driver' => 'mysql',
		'host' => env('LOG_DB_HOST', '127.0.0.1'),
		'port' => env('LOG_DB_PORT', '3306'),
		'database' => env('LOG_DB_DATABASE', 'logs_database'),
		'username' => env('LOG_DB_USERNAME', 'root'),
		'password' => env('LOG_DB_PASSWORD', ''),
		'charset' => 'utf8mb4',
		'collation' => 'utf8mb4_unicode_ci',
		'prefix' => '',
		'strict' => true,
		'engine' => null,
	],
],
```

3. Configure your database connection in `config/dblogger.php`:

```
return [
	'queue' => [
		'enabled' => env('DB_LOGGER_QUEUE_ENABLED', false),
		'connection' => env('DB_LOGGER_QUEUE_CONNECTION', 'redis'),
		'queue' => env('DB_LOGGER_QUEUE_NAME', 'logs'),
	],
	'batch' => [
		'size' => env('DB_LOGGER_BATCH_SIZE', 100),
		'timeout' => env('DB_LOGGER_BATCH_TIMEOUT', 30),
	],
	'retention' => [
		'days' => env('DB_LOGGER_RETENTION_DAYS', 90),
		'levels' => [
			'emergency' => 365,
			'alert' => 180,
			'critical' => 180,
			'error' => 90,
			'warning' => 60,
			'notice' => 30,
			'info' => 30,
			'debug' => 15,
		],
	],
];
```

4. Run the migrations:

```
php artisan migrate
```

Usage
-----

[](#usage)

### Basic Logging

[](#basic-logging)

```
use Faanigee\DbLogger\Facades\DbLogger;

// Simple logging
DbLogger::info($ref_id, $ref_type, 'User logged in successfully');

// Logging with context
DbLogger::error($ref_id, $ref_type, 'Payment failed', ['amount' => 100, 'currency' => 'USD']);
```

### Batch Logging

[](#batch-logging)

```
use Faanigee\DbLogger\Facades\DbLogger;

$entries = [
	[
		'level' => 'info',
		'ref_id' => 1,
		'ref_type' => 'user',
		'message' => 'User created',
		'context' => ['email' => 'user@example.com']
	],
	[
		'level' => 'info',
		'ref_id' => 1,
		'ref_type' => 'profile',
		'message' => 'Profile updated',
		'context' => ['fields' => ['name', 'avatar']]
	]
];

DbLogger::logBatch($entries);
```

### Asynchronous Logging

[](#asynchronous-logging)

```
use Faanigee\DbLogger\Facades\DbLogger;

// Log asynchronously using queues
DbLogger::logAsync('info', $ref_id, $ref_type, 'Processing started', ['job_id' => 123]);
```

### Enhanced Context Logging

[](#enhanced-context-logging)

```
use Faanigee\DbLogger\Facades\DbLogger;

// Log with automatically enriched context
DbLogger::logWithContext($ref_id, $ref_type, 'Action performed', ['custom' => 'data']);
```

### Available Log Levels

[](#available-log-levels)

- emergency
- alert
- critical
- error
- warning
- notice
- info
- debug

### Accessing the Log Viewer

[](#accessing-the-log-viewer)

The package comes with a built-in log viewer, just visit the following url:

- List view: `/db-logs`
- Detail view: `/db-logs/{id}`

### Configuration

[](#configuration)

You can customize the package behavior through the `config/dblogger.php` file:

- Configure the database connection
- Configure queue settings for async logging
- Set batch processing parameters
- Set log retention period
- Customize database connection
- Customize pagination settings

### Cleanup Old Logs

[](#cleanup-old-logs)

Run the cleanup command to remove old logs based on retention policy:

```
php artisan logs:cleanup
```

Or schedule it in your `App\Console\Kernel`:

```
protected function schedule(Schedule $schedule)
{
	$schedule->command('dblogger:cleanup')->daily();
}
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

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

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cac67ef1ce8d5dc27bf80e8ccb4869afc7794d54c27fe8399fdbf7740de4535?d=identicon)[faanigee](/maintainers/faanigee)

---

Top Contributors

[![irfanahmad45](https://avatars.githubusercontent.com/u/170199968?v=4)](https://github.com/irfanahmad45 "irfanahmad45 (11 commits)")

### Embed Badge

![Health badge](/badges/faanigee-dblogger/health.svg)

```
[![Health](https://phpackages.com/badges/faanigee-dblogger/health.svg)](https://phpackages.com/packages/faanigee-dblogger)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

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