adityadarma / laravel-database-logging
Logging activities database for laravel
Requires
- php: ^8.0
- laravel/framework: ^9.0|^10.0|^11.0
- 2.x-dev
- 2.4.0
- 2.3.8
- 2.3.7
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.12
- 2.1.11
- 2.1.10
- 2.1.9
- 2.1.8
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.1
- 2.0.0
- 1.x-dev
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.9
- 1.3.8
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.8
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.0
- dev-main
This package is auto-updated.
Last update: 2025-03-24 05:58:33 UTC
README
Laravel Database Logging is a feature that allows developers to store application logs in a database, rather than the default file-based storage. This feature provides a structured and organized approach to managing application logs, making it easier to query and analyze them.
Laravel Installation Instructions
-
From your projects root folder in terminal run:
composer require adityadarma/laravel-database-logging
-
Install config and asset to record the activities to:
php artisan database-logging:install
-
Run the migration to add the table to record, before running please check morph key type on config to set type column:
*Note: Before migrate, please check config
/config/database-logging.php
type data on morp relationphp artisan migrate
Configuration
Laravel Database Logging can be configured in directly in /config/database-logging.php
if you published the assets.
Or you can variables to your .env
file.
Environment File
Here are the .env
file variables available:
ENABLE_LOGGING=true LOGGING_QUERY=false
Log table other database
If you want to separate the logging table into another database, please add this:
DB_CONNECTION_LOGGING=logging DB_HOST_LOGGING= DB_PORT_LOGGING= DB_DATABASE_LOGGING= DB_USERNAME_LOGGING= DB_PASSWORD_LOGGING=
Usage
Middleware Usage
Events for laravel authentication scaffolding are listened for as providers and are enabled via middleware. You can add events to your routes and controllers via the middleware:
capture-logging
Example to start recording page views using middleware in web.php
:
Route::group(['middleware' => ['web', 'capture-logging']], function () { Route::get('/', 'WelcomeController@welcome')->name('welcome'); });
This middleware can be enabled/disabled in the configuration settings.
Trait Usage
Events can be recorded directly by using the trait. When using the trait you can customize the event description.
To use the trait:
-
Include the call in the head of your class file:
use \AdityaDarma\LaravelDatabaseLogging\Traits\DatabaseLoggable;
-
Include the trait call in the opening of your class:
use DatabaseLoggable;
Routes
Laravel Activity Dashboard Routes
Set route access from file config database-logging.php
/database-logging
Purge
Remove data logger
Set limit days data log from file config database-logging.php
then run the command
database-logging:purge
License
This Package is licensed under the MIT license. Enjoy!