Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Activitylog Laravel Package

spatie/laravel-activitylog

Log user and model activity in Laravel with a simple API. Automatically record Eloquent events, track subjects and causers, attach custom properties, and query everything via the Activity model. Stores logs in the activity_log table.

View on GitHub
Deep Wiki
Context7

title: Cleaning up the log weight: 2

After using the package for a while, you might have recorded a lot of activity. This package provides an artisan command activitylog:clean to clean the log.

Running this command will result in the deletion of all recorded activity that is older than the number of days specified in the clean_after_days key of the config file.

You can leverage Laravel's scheduler to run the clean up command now and then.

php artisan activitylog:clean
// routes/console.php

use Illuminate\Support\Facades\Schedule;

Schedule::command('activitylog:clean --force')->daily();

The --force flag is needed because the command will otherwise ask you to confirm the action when running in production. This is to prevent accidental data loss.

Define the log to clean

If you want to clean just one log, you can define it as a command argument. It will filter the log_name attribute of the Activity model.

php artisan activitylog:clean my_log_channel

Overwrite the days to keep per call

You can define the days to keep for each call as a command option. This will overwrite the config for this run.

php artisan activitylog:clean --days=7

MySQL: rebuild index and reclaim space after clean

After cleaning, the database table might still use more space than expected. You can run the following MySQL commands to reclaim space:

OPTIMIZE TABLE activity_log;

or

ANALYZE TABLE activity_log;

*These SQL operations will lock read/write access to the database. Only run them when the server is in maintenance mode.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport