The webqamdev/activity-logger package automatically log model changes from users into database and log files.
This package use spatie/laravel-activitylog to store logs in database. Feel free to configure it if needed or just follow Installation instructions.
You can install the package via composer:
composer require webqamdev/activity-loggerThe package will automatically register itself.
Configure spatie/laravel-activitylog. By default, run those commands :
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
php artisan migrateYou can optionally publish the config file with:
php artisan vendor:publish --provider="Webqamdev\ActivityLogger\ActivityLoggerServiceProvider" --tag="config"Publish config file. Then add entries to properties_hidden array.
Create your model normally, then define hidden properties.
class User extends Model {
/**
* The attributes that shouldn't be logged in activity logger.
*
* @var array
*/
public $logAttributesToIgnore = [
'password',
'phone',
];
...
}Add ACTIVITY_LOGGER_TO_DATABASE=false to your .env file will prevent logger from writing into database.
If not already done, publish config file:
php artisan vendor:publish --provider="Webqamdev\ActivityLogger\ActivityLoggerServiceProvider" --tag="config"Add channel.permission to your config/activitylogger.php file like this exemple:
'channel' => [
'path' => storage_path('logs/activity.log'),
'level' => 'debug',
'days' => 14,
'permission' => 0644, // Default value, equivalent to bash's rw-r--r--
],Please see UPGRADING for details.
This package using Laravel 5.8 is a plugin for auto-logging activities.
Gitlab repository : Activity logger for Laravel Github repository : Activity logger for Laravel