lancodev/laravel-logging is a Laravel package for this is my package laravel-logging.
It currently has 0 GitHub stars and 1.201 downloads on Packagist (latest version 0.7).
Install it with composer require lancodev/laravel-logging.
Discover more Laravel packages by lancodev
or browse all Laravel packages to compare alternatives.
Last updated
This package provides a simple way to log events to a database table. It provides a convenient Loggable Trait to allow you to link your logs to a model. It also provides a Log model that you can use to query your logs.
You can install the package via composer:
composer require lancodev/laravel-logging
You can publish and run the migrations with:
php artisan vendor:publish --tag="laravel-logging-migrations"
php artisan migrate
Add the Loggable Trait to your model(s) that you want to log events for.
Then, you can create logs for the model using the logs relationship:
$model->logs()->create([
'type' => 'Info',
'log' => 'lorem ipsum',
]);
To view logs for a given model, you can use the logs relationship:
$model->logs;
Or use standard Eloquent query language to filter the logs by type, etc:
$model->logs()->where('type', 'Info')->get();
Lancodev\LaravelLogging\Models\Log {
id: 1,
loggable_type: "App\Models\{SOME_MODEL}",
loggable_id: 1,
type: "Info",
log: "lorem ipsum",
created_at: "2023-01-01 00:00:00",
updated_at: "2023-01-01 00:00:00",
},
The Log model also has a loggable relationship that allows you to access the model that the log belongs to:
$log->loggable;****
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.