PHPackages                             leek/laravel-compact-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. leek/laravel-compact-logs

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

leek/laravel-compact-logs
=========================

Truncate verbose stack traces in Laravel log files for cleaner, more readable logs.

21.1k↓16.7%PHP

Since Feb 13Pushed 3mo agoCompare

[ Source](https://github.com/leek/laravel-compact-logs)[ Packagist](https://packagist.org/packages/leek/laravel-compact-logs)[ RSS](/packages/leek-laravel-compact-logs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel Compact Logs
====================

[](#laravel-compact-logs)

Truncate verbose stack traces in Laravel log files. Instead of 100+ line stack traces per error, get the error message and the first few relevant frames.

**Before:**

```
[2026-02-12 08:37:31] local.ERROR: Connection refused {"exception":"[object] (PDOException...)
[stacktrace]
#0 /vendor/laravel/framework/src/.../Connection.php(420): PDO->prepare(...)
#1 /vendor/laravel/framework/src/.../Connection.php(827): ...
#2 /vendor/laravel/framework/src/.../Connection.php(794): ...
#3 /vendor/laravel/framework/src/.../Connection.php(411): ...
... 80 more lines of framework internals ...

```

**After:**

```
[2026-02-12 08:37:31] local.ERROR: Connection refused {"exception":"[object] (PDOException...)
[stacktrace]
#0 /vendor/laravel/framework/src/.../Connection.php(420): PDO->prepare(...)
#1 /vendor/laravel/framework/src/.../Connection.php(827): ...
#2 /vendor/laravel/framework/src/.../Connection.php(794): ...
... and 80 more frames"}

```

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

[](#installation)

```
composer require leek/laravel-compact-logs
```

That's it. The package auto-registers and applies to `single` and `daily` log channels by default.

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

[](#configuration)

Publish the config file to customize:

```
php artisan vendor:publish --tag=compact-logs-config
```

```
// config/compact-logs.php
return [
    // Channels to apply truncation to (set to null to disable auto-registration)
    'channels' => ['single', 'daily'],

    // Max stack trace frames per exception
    'max_trace_depth' => (int) env('LOG_TRACE_DEPTH', 3),
];
```

### Environment Variable

[](#environment-variable)

```
LOG_TRACE_DEPTH=5
```

### Manual Setup

[](#manual-setup)

If you prefer manual control, set `channels` to `null` in the config and add the tap directly to your `config/logging.php`:

```
'single' => [
    'driver' => 'single',
    'tap'    => [\Leek\CompactLogs\CompactExceptionTap::class],
    'path'   => storage_path('logs/laravel.log'),
    'level'  => env('LOG_LEVEL', 'debug'),
],
```

How It Works
------------

[](#how-it-works)

The package provides a custom Monolog `LineFormatter` that overrides `normalizeException()` to truncate stack traces. A logging [tap](https://laravel.com/docs/logging#customizing-monolog-for-channels) applies this formatter to your configured channels.

- Stack traces are trimmed to `max_trace_depth` frames (default: 3)
- A `... and N more frames` indicator shows how many were omitted
- Previous exception chains are also truncated
- All other log formatting remains unchanged

License
-------

[](#license)

MIT

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance55

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/e11ad2f75cb1d558136f1982458d541d96fb84a217d6a82e8c18df2ff503964b?d=identicon)[leek](/maintainers/leek)

---

Top Contributors

[![leek](https://avatars.githubusercontent.com/u/60204?v=4)](https://github.com/leek "leek (2 commits)")

---

Tags

laravellaravel-package

### Embed Badge

![Health badge](/badges/leek-laravel-compact-logs/health.svg)

```
[![Health](https://phpackages.com/badges/leek-laravel-compact-logs/health.svg)](https://phpackages.com/packages/leek-laravel-compact-logs)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[ekino/newrelic-bundle

Integrate New Relic into Symfony2

28111.2M8](/packages/ekino-newrelic-bundle)

PHPackages © 2026

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