Laravel Activitylog
Records and queries a full audit trail of activity inside your Laravel application
Repository Health
Technical Analysis
Laravel Activitylog by Spatie logs meaningful events that happen in a Laravel application — model changes, custom events, and user actions — to a database table that can be queried like any other Eloquent model. It ships an Activity model, a LogsActivity trait for Eloquent models, and a fluent activity() helper for logging arbitrary events.
With the trait applied, the package automatically records create/update/delete changes on a model, including old and new attribute values, and associates each log entry with a causer (typically the authenticated user) and an optional subject. This gives applications a queryable audit trail without hand-rolling event listeners or a bespoke logging table.
What You Get
- A
LogsActivitytrait that auto-logs Eloquent model create/update/delete events with before/after attribute diffs - A fluent
activity()/ActivityLoggerAPI for logging custom, non-model events - An
ActivityEloquent model withcauser/subjectrelations for querying who did what to which record - Configurable log names, per-attribute logging rules, and event descriptions
- Artisan commands for cleaning up old log entries past a retention period
Common Use Cases
- Building an admin-facing audit trail showing who changed what and when on key models
- Compliance logging for regulated applications that must retain a history of data changes
- Debugging support tickets by reconstructing the sequence of changes to a customer’s record
- Logging custom business events (e.g. ‘invoice sent’, ‘subscription cancelled’) alongside model changes
Under The Hood
Architecture - ActivitylogServiceProvider binds a config-driven Activity model and registers the LogsActivity trait’s model-observer hooks (created/updated/deleted) so any Eloquent model that uses the trait gets logged transparently; a separate ActivityLogger/activity() facade path handles ad-hoc, non-model event logging through the same underlying Activity writer. Log entries are persisted to a migration-generated activity_log table with polymorphic subject/causer columns, keeping the audit trail queryable via normal Eloquent relations. Tech Stack - Laravel-only PHP package (illuminate/* contracts, no external services), using a standard Laravel migration/model/trait/facade structure; retention cleanup runs through a scheduled Artisan command rather than a queue worker. Code Quality - 26 test files cover model-change logging, attribute diffing, causer/subject resolution, and log cleanup; the package has shipped 100 tagged releases over nearly a decade, indicating sustained, incremental maintenance rather than large rewrites. API Design - Adoption is a one-line use LogsActivity; on a model plus an optional getActivitylogOptions() override for fine-grained control (which attributes to log, custom descriptions), and the activity()->log() helper mirrors Laravel’s own facade-style ergonomics, keeping the learning curve low for teams already familiar with Eloquent.
Used by 2 apps in this directory
Coolify
Devops · Hosting Control Panel
Open-source self-hosted PaaS — deploy apps, databases and 280+ services on your own servers with no vendor lock-in
FreeScout
Customer Support
Run your own help desk and shared inbox — a fully self-hosted, open-source alternative to Zendesk and Help Scout with no per-agent fees.