PHPackages                             maksudur-dev/laravel-logpilot - 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. maksudur-dev/laravel-logpilot

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

maksudur-dev/laravel-logpilot
=============================

A lightweight activity logging package for Laravel with request tracing.

v1.0.1(1mo ago)11MITPHPPHP ^7.3|^8.0

Since Apr 24Pushed 1mo agoCompare

[ Source](https://github.com/maksudur-dev/laravel-logpilot)[ Packagist](https://packagist.org/packages/maksudur-dev/laravel-logpilot)[ Docs](https://github.com/maksudur-dev/laravel-logpilot)[ RSS](/packages/maksudur-dev-laravel-logpilot/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

Laravel LogPilot
================

[](#laravel-logpilot)

[![Latest Version on Packagist](https://camo.githubusercontent.com/5aa095635638b6542bbc7d4fd3775653b8c002639c29ab3b7de1686ead11a2ac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616b73756475722d6465762f6c61726176656c2d6c6f6770696c6f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maksudur-dev/laravel-logpilot)[![Total Downloads](https://camo.githubusercontent.com/4b83ceaa0218c91575645154a9cf7c5a4365012c3c1062f3121b3eccbcbecca0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d616b73756475722d6465762f6c61726176656c2d6c6f6770696c6f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maksudur-dev/laravel-logpilot)[![License](https://camo.githubusercontent.com/93e6bbffa26d8abec34688e1494f8bda49a4fccba66474f8d165912e60dc06f8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d616b73756475722d6465762f6c61726176656c2d6c6f6770696c6f742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/maksudur-dev/laravel-logpilot)

A lightweight Laravel activity logging package that improves debugging, tracing, and business-event visibility while using Laravel's EXISTING logging system or a database.

Key Features
------------

[](#key-features)

- **Request Tracing**: Group multiple logs under a single `log_id` automatically.
- **Dual Drivers**: Support for Laravel Logs, Database, or both.
- **Auto-Context**: Automatically captures User ID, IP, URL, and Method.
- **Model Support**: Easily associate activities with Eloquent models.
- **API Support**: Optional API endpoints to view activity logs.
- **Artisan Commands**: Install, prune, and test your setup easily.
- **Lightweight**: Zero-config by default, minimal overhead.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require maksudur-dev/laravel-logpilot
```

Run the installation command:

```
php artisan activity:install
```

If you are using the `database` driver, run the migrations:

```
php artisan migrate
```

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

[](#configuration)

The configuration file is located at `config/logpilot.php`.

```
return [
    'enabled' => env('LOGPILOT_ENABLED', true),
    'driver' => env('LOGPILOT_DRIVER', 'log'), // log, database, both
    'channel' => env('LOGPILOT_CHANNEL', null), // default log channel
    'auto_group_id' => true,
    'store_request_context' => true,
    'api_enabled' => env('LOGPILOT_API_ENABLED', false),
    'queue' => env('LOGPILOT_QUEUE', false),
    'retention_days' => 30,
];
```

Usage
-----

[](#usage)

### 1. Global Helper (Quickest)

[](#1-global-helper-quickest)

```
activity('user_login');

// With details
activity('profile_updated', $user, 'User updated their profile photo');

// With array message (automatically cast to JSON)
activity('api_response', null, [
    'status' => 'success',
    'data' => ['id' => 1]
]);

// Full control
activity(
    action: 'withdraw_request',
    model: $user,
    message: 'Gateway timeout',
    level: 'error',
    meta: ['amount' => 500]
);
```

### 2. Eloquent Trait (Recommended for Models)

[](#2-eloquent-trait-recommended-for-models)

Add the `LogsActivity` trait to your models:

```
use LaravelLogPilot\Traits\LogsActivity;

class Order extends Model
{
    use LogsActivity;
}

// Now you can do:
$order->logActivity('shipped', 'Order has been shipped to customer');

// Retrieve logs for this model:
$logs = $order->activities;
```

### 3. Service Usage

[](#3-service-usage)

Inject the `ActivityLogger` service into your classes:

```
use LaravelLogPilot\Services\ActivityLogger;

class PaymentService
{
    public function __construct(protected ActivityLogger $logger) {}

    public function process()
    {
        $this->logger->log('payment_started');
    }
}
```

### 4. Grouping Related Logs (Tracing)

[](#4-grouping-related-logs-tracing)

Perfect for complex flows like checkouts or background jobs:

```
activity_group('checkout_flow_001');

activity('cart_validated');
activity('payment_processing');
activity('order_created'); // All will share log_id: checkout_flow_001
```

Frontend Integration (Vue/React Example)
----------------------------------------

[](#frontend-integration-vuereact-example)

Since LogPilot provides an API, you can easily build a "Recent Activity" component.

### Example Vue Component

[](#example-vue-component)

```

      {{ log.action }}
      {{ log.message }}
      {{ JSON.stringify(log.message, null, 2) }}
      {{ formatDate(log.created_at) }}

import { ref, onMounted } from 'vue';

const props = defineProps(['modelType', 'modelId']);
const logs = ref([]);

onMounted(async () => {
  const response = await fetch(`/api/activity-logs/model/${props.modelType}/${props.modelId}`);
  const data = await response.json();
  logs.value = data.data;
});

```

### Example React Component

[](#example-react-component)

```
import React, { useState, useEffect } from 'react';

const ActivityFeed = ({ modelType, modelId }) => {
  const [logs, setLogs] = useState([]);

  useEffect(() => {
    fetch(`/api/activity-logs/model/${modelType}/${modelId}`)
      .then(res => res.json())
      .then(data => setLogs(data.data));
  }, [modelType, modelId]);

  return (

      {logs.map(log => (

          {log.action}
          {typeof log.message === 'object' ? (
            {JSON.stringify(log.message, null, 2)}
          ) : (
            {log.message}
          )}
          {new Date(log.created_at).toLocaleString()}

      ))}

  );
};

export default ActivityFeed;
```

### Example Blade Component

[](#example-blade-component)

If you prefer server-side rendering, you can pass logs to a Blade component:

```
{{-- In your controller --}}
$logs = $order->activities()->paginate(10);
return view('orders.show', compact('order', 'logs'));

{{-- In orders/show.blade.php --}}

    @foreach($logs as $log)

            {{ $log->action }}

                @if(is_array($log->message))
                    {{ json_encode($log->message, JSON_PRETTY_PRINT) }}
                @else
                    {{ $log->message }}
                @endif

            {{ $log->created_at->diffForHumans() }}

    @endforeach
    {{ $logs->links() }}

```

API Support
-----------

[](#api-support)

LogPilot exposes clean, JSON-ready endpoints:

- `GET /api/activity-logs`: All logs.
- `GET /api/activity-logs/trace/{log_id}`: Trace a full request lifecycle.
- `GET /api/activity-logs/model/{type}/{id}`: Activity for a specific resource.

Artisan Commands
----------------

[](#artisan-commands)

- `php artisan activity:install`: Setup everything.
- `php artisan activity:prune`: Cleanup old logs.
- `php artisan activity:test`: Verify installation.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/928e863a0deab5bd3eb0f4c13cc6e658c7c41ffb1287b9721ec28500a25fc50c?d=identicon)[valiantboymaksud](/maintainers/valiantboymaksud)

---

Tags

laravelloggingdebuggingtracingactivity-log

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/maksudur-dev-laravel-logpilot/health.svg)

```
[![Health](https://phpackages.com/badges/maksudur-dev-laravel-logpilot/health.svg)](https://phpackages.com/packages/maksudur-dev-laravel-logpilot)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.4k](/packages/larastan-larastan)[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k28.4M134](/packages/laravel-cashier)[spatie/laravel-health

Monitor the health of a Laravel application

87311.3M149](/packages/spatie-laravel-health)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9732.3M121](/packages/roots-acorn)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

15104.9k4](/packages/calebdw-larastan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
