PHPackages                             litepie/logs - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. litepie/logs

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

litepie/logs
============

A comprehensive activity log package for Laravel applications

v1.0.2(6mo ago)0352MITPHPPHP ^8.2|^8.3CI failing

Since Aug 23Pushed 6mo agoCompare

[ Source](https://github.com/Litepie/Logs)[ Packagist](https://packagist.org/packages/litepie/logs)[ Fund](https://litepie.com/sponsor)[ RSS](/packages/litepie-logs/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (4)Used By (2)

Litepie Logs
============

[](#litepie-logs)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3424a77de4511826c78004d0ebd74deb1408ab6662bc9125793c0720a37c5416/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6974657069652f6c6f67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/litepie/logs)[![GitHub Tests Action Status](https://camo.githubusercontent.com/153329bf908c1a7de7808ca09f07b2fad986eacc6afd6dddbfe1d8b5765f35da/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c6974657069652f6c6f67732f74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/litepie/logs/actions?query=workflow%3Atests+branch%3Amaster)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/4e791e12dc4859f4ef66c5c74191d2ed1396a9fcd16d493b3de30a09f273dea1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c6974657069652f6c6f67732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d6173746572266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/litepie/logs/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amaster)[![PHPStan Analysis](https://camo.githubusercontent.com/423f97a557354036c434985657ced3db1912b9d4074870ec18f866b5dbd9cb68/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6c6974657069652f6c6f67732f7068707374616e2e796d6c3f6272616e63683d6d6173746572266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/litepie/logs/actions?query=workflow%3Aphpstan+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/a39ab49a2904a3822f1f91e0b0f6dd35fe336adf141732eba10f61728e0d7e91/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6974657069652f6c6f67732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/litepie/logs)[![License](https://camo.githubusercontent.com/d1da12143ea27220aa2c2d1c5d4b12f47e6aa3cdb03b6d02d1979337a33e2648/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c6974657069652f6c6f67733f7374796c653d666c61742d737175617265)](https://packagist.org/packages/litepie/logs)

A comprehensive and powerful activity logging package for Laravel applications that provides detailed tracking and auditing capabilities with enhanced foreign key resolution, batch operations, and advanced filtering.

Features
--------

[](#features)

- 🚀 **Automatic Model Logging** - Track model changes automatically with the `LogsActivity` trait
- 🔍 **Enhanced Foreign Key Resolution** - Automatically resolve foreign keys to human-readable names
- 📦 **Batch Operations** - Group related activities with batch UUIDs
- ⚡ **Queue Support** - Process logs asynchronously for better performance
- 🗂️ **Database Partitioning** - Monthly partitioning for large datasets
- 🛡️ **Privacy Protection** - Anonymize sensitive data and exclude fields
- 📊 **Advanced Filtering** - Rich querying and filtering capabilities
- 📈 **Statistics &amp; Analytics** - Built-in activity statistics and reporting
- 🔄 **Export Functionality** - Export logs in multiple formats (CSV, JSON, PDF)
- 🎯 **Retention Policies** - Configurable data retention with automatic cleanup
- 🌐 **API Support** - Optional API routes for external access
- 🧪 **Comprehensive Testing** - Full test suite with PHPUnit

📖 Quick Start
-------------

[](#-quick-start)

### 1. Install the Package

[](#1-install-the-package)

```
composer require litepie/logs
```

### 2. Publish Configuration &amp; Run Migrations

[](#2-publish-configuration--run-migrations)

```
php artisan vendor:publish --provider="Litepie\Logs\LogsServiceProvider" --tag="config"
php artisan migrate
```

### 3. Add the Trait to Your Model

[](#3-add-the-trait-to-your-model)

```
use Litepie\Logs\Traits\LogsActivity;

class User extends Model
{
    use LogsActivity;

    protected $fillable = ['name', 'email'];
}
```

### 4. That's It! 🎉

[](#4-thats-it-)

All model changes are now automatically logged:

```
$user = User::create(['name' => 'John', 'email' => 'john@example.com']);
// ✅ Logged: "User created"

$user->update(['name' => 'Jane']);
// ✅ Logged: "User updated" with change details

$user->delete();
// ✅ Logged: "User deleted"
```

---

---

📋 Requirements
--------------

[](#-requirements)

- **PHP**: 8.2, 8.3, or 8.4
- **Laravel**: 10.x, 11.x, or 12.x
- **Database**: MySQL 5.7+ (for partitioning features), PostgreSQL, SQLite

🚀 Installation
--------------

[](#-installation)

### Option 1: Quick Install (Recommended)

[](#option-1-quick-install-recommended)

```
# Install the package
composer require litepie/logs

# Publish config and run migrations
php artisan vendor:publish --provider="Litepie\Logs\LogsServiceProvider" --tag="config"
php artisan migrate
```

### Option 2: Custom Installation

[](#option-2-custom-installation)

```
# Install package
composer require litepie/logs

# Publish config file (optional)
php artisan vendor:publish --provider="Litepie\Logs\LogsServiceProvider" --tag="config"

# Publish migrations (if you want to customize)
php artisan vendor:publish --provider="Litepie\Logs\LogsServiceProvider" --tag="migrations"

# Run migrations
php artisan migrate
```

> 💡 **Tip**: The package will automatically register its service provider in Laravel 5.5+

Configuration
-------------

[](#configuration)

The configuration file `config/logs.php` provides extensive customization options:

```
return [
    // Enable/disable activity logging
    'enabled' => env('ACTIVITY_LOG_ENABLED', true),

    // Default log name
    'default_log_name' => env('ACTIVITY_LOG_DEFAULT_NAME', 'default'),

    // Database table name
    'table_name' => env('ACTIVITY_LOG_TABLE_NAME', 'activity_logs'),

    // Automatic cleanup (days)
    'delete_records_older_than_days' => env('ACTIVITY_LOG_DELETE_RECORDS_OLDER_THAN_DAYS', 365),

    // Queue settings
    'queue_logs' => env('ACTIVITY_LOG_QUEUE_LOGS', false),
    'queue_connection' => env('ACTIVITY_LOG_QUEUE_CONNECTION', 'default'),

    // Performance optimizations
    'enable_partitioning' => env('ACTIVITY_LOG_ENABLE_PARTITIONING', false),
    'batch_size' => env('ACTIVITY_LOG_BATCH_SIZE', 1000),

    // Privacy settings
    'privacy' => [
        'anonymize_ip' => env('ACTIVITY_LOG_ANONYMIZE_IP', false),
        'exclude_fields' => ['password', 'password_confirmation', 'remember_token'],
        'hash_sensitive_data' => env('ACTIVITY_LOG_HASH_SENSITIVE', false),
    ],

    // And many more options...
];
```

Basic Usage
-----------

[](#basic-usage)

### Automatic Model Logging

[](#automatic-model-logging)

Add the `LogsActivity` trait to any model you want to track:

```
