laravel-database-logger maintained by jhonoryza
Author
Last update
2025/12/23 11:26
(dev-main)
License
Downloads
26
Laravel Database Logger
This package provides ability to store laravel log to the database table.
Requirement
- PHP 8.1 - 8.4
- Laravel 9, 10, 11, 12
Getting Started
- install
composer require jhonoryza/laravel-database-logger
- publish config files
php artisan vendor:publish --tag laravel-database-logger
-
check the
logging-dbconfig file and change logger db connection. -
it is recommended to use different database connection from the main used one.
-
after package is installed, you can run
php artisan migrateto create tablelogs_appandlogs_api -
then modify
logging.php- add
databasechannel to thestackchannel
<?php 'stack' => [ 'driver' => 'stack', 'channels' => ['daily', 'database'], 'ignore_exceptions' => true, ],- add in
.envfile to setDB_CONNECTION_LOGGER=pgsql
- add
Additional API Logger
register the macro
<?php
use Jhonoryza\DatabaseLogger\Logging\ApiLogger;
class ServiceProvider
{
public function boot()
{
ApiLogger::registerMacro();
}
}
to automatically add api logger to the database call logRequest function
<?php
use Illuminate\Support\Facades\Http;
$response = Http::logRequest()
->withHeaders(['X-Foo' => 'Bar'])
->post('https://api.example.com/v1/users?id=123', [
'name' => 'Fajar',
]);
Additional Repository
<?php
use Jhonoryza\DatabaseLogger\Repositories\LogAppRepository;
use Jhonoryza\DatabaseLogger\Repositories\LogApiRepository;
LogAppRepository::getAllList(limit: 10);
LogAppRepository::getSimplePaginateList(perPage: 10);
LogAppRepository::getPaginateList(perPage: 10);
LogAppRepository::getCursorList(perPage: 10);
LogAppRepository::getDetail(id: 1);
LogApiRepository::getAllList(limit: 10);
LogApiRepository::getSimplePaginateList(perPage: 10);
LogApiRepository::getPaginateList(perPage: 10);
LogApiRepository::getCursorList(perPage: 10);
LogApiRepository::getDetail(id: 1);
Screenshot




Security
If you've found a bug regarding security, please mail jardik.oryza@gmail.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.