PHPackages                             laikmosh/plog - 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. laikmosh/plog

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

laikmosh/plog
=============

Advanced Laravel logging system with metadata capture, tagging, and powerful filtering

1.0.8(8mo ago)053MITPHPPHP ^8.2

Since Nov 29Pushed 1mo agoCompare

[ Source](https://github.com/laikmosh/plog)[ Packagist](https://packagist.org/packages/laikmosh/plog)[ RSS](/packages/laikmosh-plog/feed)WikiDiscussions main Synced 1w ago

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

Plog - Advanced Laravel Logging Package
=======================================

[](#plog---advanced-laravel-logging-package)

Plog is a powerful Laravel logging enhancement package that captures extensive metadata, supports tagging, and provides an interactive web interface for log exploration.

Features
--------

[](#features)

- **Automatic Metadata Capture**: User ID, Session ID, Request ID, file/line, class/method
- **Request Tracking**: Track logs across HTTP requests, queued jobs, and CLI commands
- **Tagging System**: Organize logs with tags for easy filtering
- **Interactive Web Interface**: Filter, search, and explore logs with Livewire + Alpine.js
- **Flexible Storage**: SQLite by default, configurable to any Laravel database
- **Granular Retention**: Configure different retention periods for different log types

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

[](#installation)

```
composer require laikmosh/plog
```

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

[](#configuration)

Publish the configuration file and assets:

```
php artisan vendor:publish --tag=plog-config
php artisan vendor:publish --tag=plog-assets
```

Run migrations:

```
php artisan migrate
```

### Environment Variables

[](#environment-variables)

```
# Enable/disable Plog
PLOG_ENABLED=true

# Authorized emails (comma-separated)
PLOG_AUTHORIZED_EMAILS=admin@example.com,developer@example.com

# Database connection (optional, defaults to SQLite)
PLOG_DB_CONNECTION=plog

# Default retention period
PLOG_RETENTION_DAYS=7

# Enable automatic cleanup
PLOG_CLEANUP_ENABLED=true
```

Usage
-----

[](#usage)

### Basic Logging

[](#basic-logging)

All existing Laravel log calls automatically capture metadata:

```
Log::info('User logged in', ['user_id' => $user->id]);
Log::error('Payment failed', ['order_id' => $orderId]);
```

### Using Tags

[](#using-tags)

Add tags through the `plog:tags` context key — the one and only tagging syntax:

```
use Illuminate\Support\Facades\Log;

Log::info('Order processed', [
    'order_id' => $orderId,
    'plog:tags' => ['payment', 'stripe'],
]);

Log::error('Connection failed', ['plog:tags' => ['database', 'error']]);

Log::warning('Slow query', [
    'time' => 2.5,
    'plog:tags' => ['performance', 'database'],
]);

// The plog:tags key is extracted and stored as queryable tags;
// it never appears in the stored context data.
```

This works with all Laravel log methods on any channel. Because the key is a plain string literal (never a plog class constant or method), call sites survive uninstalling plog: standard Laravel simply logs the key as ordinary context, and nothing breaks. The vendor-namespaced `plog:` prefix keeps it from colliding with real context keys.

The same convention carries durations: pass `'plog:response_time' => $seconds` in context and plog lifts it into the entry's `response_time` column.

### Watchers

[](#watchers)

Opt-in watchers record framework activity as regular entries — filterable by tag, correlated with the request that caused them, and carrying the app call site like any other entry. Both are configured under `plog.watchers` and disabled by default.

**Redis** (`plog.watchers.redis`) — records commands via Laravel's `CommandExecuted`/`CommandFailed` events, tagged `redis` and `redis:`, with the duration in `response_time`. Guardrails: `slower_than` (ms threshold; `0` records everything), `ignore_commands`, and wildcard `ignore_key_patterns` (Horizon and queue chatter is ignored out of the box). Failed commands log as warnings.

**Models** (`plog.watchers.models`) — records Eloquent lifecycle events (`created`, `updated`, `deleted`, `restored`, `forceDeleted` — exactly the hooks observers run on), tagged `eloquent` and `eloquent:`. Updates store the changed attributes (values truncated), creates store attribute names, deletes log at `info` level. Configure `events` to narrow the list and `ignore` to skip model classes; plog's own models are always skipped.

### Viewing Logs

[](#viewing-logs)

Access the web interface at the path configured in `plog.route.path` — `/logs` by default, overridable via `PLOG_ROUTE_PATH` (requires authentication and authorization).

The interface allows you to:

- Filter by level, user, request ID, session, environment, endpoint, and tags
- Search through log messages and context
- Click any field to instantly filter by that value
- View detailed log entries with full context
- Group logs by request to trace execution flow

### Database Viewer

[](#database-viewer)

A second section of the web UI (the **Database** link in the header, or `/logs/db`) browses and edits the host app's databases:

- **Left column** — every configured connection (default preselected), and the selected connection's tables from live schema introspection. Tables backed by an Eloquent model show a badge; models are auto-discovered by scanning `plog.db.model_paths` (defaults to `app/Models`) and correlated by table + connection.
- **Middle column** — column/operator/value filters, free-text search across text columns, sortable headers, and incremental "load more" pagination. Model-backed tables get a collapsible intel strip: relations, casts, fillable/guarded/hidden, dispatched events, observers, `rules()`, global scopes.
- **Right column** — the selected record with type-aware editable fields (bool checkboxes, datetime pickers, JSON textareas with validation, NULL toggles), Save/Delete (soft-delete aware), and relationship chips that navigate to related records. A breadcrumb trail tracks the navigation; each crumb's ▾ lists its siblings.

Behavior worth knowing:

- Listing reads through the query builder (global scopes don't hide rows; soft-deleted rows are tinted). Writes go through the model when one exists — via `forceFill`, and **model events, observers and the model watcher fire**. If the model defines `rules()`, changed columns are validated before saving.
- Tables without a single-column primary key are browse-only.
- Access is gated by `viewPlogDb` (defaults to the `viewPlog` email allowlist — an empty allowlist means everyone). Set `PLOG_DB_READONLY=true` to disable all writes server-side; `PLOG_DB_ENABLED=false` removes the section entirely.

```
'db' => [
    'enabled' => env('PLOG_DB_ENABLED', true),
    'read_only' => env('PLOG_DB_READONLY', false),
    'connections' => ['only' => [], 'exclude' => []],
    'model_paths' => [],          // relative to base_path(); empty ⇒ app/Models
    'model_exclude' => [],        // class names or glob patterns
    'model_cache_ttl' => 300,     // seconds; 0 disables the discovery cache
    'per_page' => 50,
    'list_columns' => 8,
    'sibling_limit' => 25,
    'hidden_tables' => [],
],
```

On Laravel 10 without `doctrine/dbal`, column types can't be introspected and the viewer degrades to read-only browsing; Laravel 11+ needs nothing extra.

Advanced Configuration
----------------------

[](#advanced-configuration)

### Custom Database Connection

[](#custom-database-connection)

In `config/plog.php`:

```
'database' => [
    'connection' => 'mysql', // Use your app's main database
    'table' => 'plog_entries',
],
```

### Retention Policies

[](#retention-policies)

Configure granular retention rules:

```
'retention' => [
    'default_days' => 7,
    'rules' => [
        ['tags' => ['payment'], 'days' => 30],
        ['tags' => ['authentication'], 'days' => 90],
        ['level' => 'error', 'days' => 14],
    ],
],
```

### Authorization

[](#authorization)

Control access via email whitelist:

```
'authorized_emails' => [
    'admin@example.com',
    'developer@example.com',
],
```

Or customize the gate in your `AuthServiceProvider`:

```
Gate::define('viewPlog', function ($user) {
    return $user->hasRole('admin');
});
```

Request ID Tracking
-------------------

[](#request-id-tracking)

Plog automatically generates and tracks request IDs across:

- HTTP requests
- Queued jobs (preserves original request ID)
- CLI commands

Access the current request ID:

```
use Laikmosh\Plog\Services\RequestIdService;

$requestId = app(RequestIdService::class)->getRequestId();
```

Captured Metadata
-----------------

[](#captured-metadata)

Each log entry captures:

- **Time**: Timestamp with microseconds
- **Level**: debug, info, notice, warning, error, critical, alert, emergency
- **Message**: Log message
- **Context**: Additional data passed to the log
- **User ID**: Currently authenticated user
- **Session ID**: Current session identifier
- **Request ID**: Unique request identifier
- **Environment**: http, cli, queue, testing
- **Endpoint**: Route name or URI, CLI command
- **File &amp; Line**: Source code location
- **Class &amp; Method**: Calling class and method
- **Tags**: Custom tags for organization

Performance Considerations
--------------------------

[](#performance-considerations)

- Logs are written synchronously by default
- Consider using a dedicated database for high-volume applications
- Indexes are automatically created for common query patterns
- Use retention policies to manage database size

License
-------

[](#license)

MIT

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance78

Regular maintenance activity

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~1 days

Total

8

Last Release

253d ago

PHP version history (2 changes)1.0.0PHP ^8.1

1.0.2PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1bd30c4d9a8794e2e07ec6a2595dbb6e233d19ed093bc4143f4023702a648684?d=identicon)[laikmosh](/maintainers/laikmosh)

---

Top Contributors

[![laikmosh](https://avatars.githubusercontent.com/u/11953474?v=4)](https://github.com/laikmosh "laikmosh (17 commits)")

---

Tags

laravelloggingmonitoringdebuggingplog

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laikmosh-plog/health.svg)

```
[![Health](https://phpackages.com/badges/laikmosh-plog/health.svg)](https://phpackages.com/packages/laikmosh-plog)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k161.4k2](/packages/mike-bronner-laravel-model-caching)[forjedio/inertia-table

Backend-driven dynamic tables for Laravel + Inertia.js

272.0k](/packages/forjedio-inertia-table)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[anousss007/vigilance

A driver-agnostic control center for Laravel queues, jobs, commands and the scheduler. Monitor what ran (with parameters), see failures, and dispatch jobs or run artisan commands manually from a self-contained dashboard.

1939.9k](/packages/anousss007-vigilance)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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