PHPackages                             mxnwire/laravel-logbarrel - 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. mxnwire/laravel-logbarrel

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

mxnwire/laravel-logbarrel
=========================

Log every incoming HTTP request (and optionally its response) to a dedicated channel, with redaction and fine-grained options

1.0.0(1mo ago)01MITPHPPHP ^8.1

Since Jun 14Pushed 1mo agoCompare

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

READMEChangelogDependencies (4)Versions (2)Used By (0)

Laravel LogBarrel
=================

[](#laravel-logbarrel)

Log every incoming HTTP request — and optionally its response — to a dedicated channel, with sensitive-field redaction and fine-grained capture options. Drop it in and get a clean, queryable record of the traffic hitting your app.

Each request is written as a single log entry whose context holds the captured request and response data, for example:

```
{
    "method": "POST",
    "url": "https://app.test/login",
    "route": "login",
    "query": [],
    "body": { "email": "a@b.com", "password": "[REDACTED]" },
    "ip": "203.0.113.4",
    "user_agent": "Mozilla/5.0 ...",
    "user_id": 42,
    "user_email": "a@b.com",
    "status": 200,
    "duration_ms": 18.42
}
```

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

[](#installation)

```
composer require mxnwire/laravel-logbarrel
```

The service provider is auto-discovered. By default the middleware is appended to the global HTTP stack, so every web/api request is logged with no further setup.

By default entries are written to a `requests` channel. Define it in `config/logging.php` (or set `LOGBARREL_CHANNEL=stack`/`null` to use your default):

```
'channels' => [
    'requests' => [
        'driver' => 'daily',
        'path' => storage_path('logs/requests.log'),
        'days' => 14,
    ],
],
```

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

[](#configuration)

Publish the config to customise behaviour:

```
php artisan vendor:publish --tag=logbarrel-config
```

Key options in `config/logbarrel.php`:

- `enabled` — master switch; when false the middleware passes requests through untouched (`LOGBARREL_ENABLED`).
- `register_global_middleware` — when false, register manually with the `logbarrel` alias instead of the global stack.
- `channel` / `level` / `message` — where, at what level and with what message each entry is logged. `channel: null` uses the default channel.
- `middleware_groups` — only log requests whose matched route is in one of these groups (default `web`, `api`). Empty array logs everything, including unrouted requests.
- `except_paths` — glob patterns (`Str::is`) whose paths are never logged (e.g. `telescope*`, `_debugbar*`).
- `request` — toggle capture of `method`, `url`, `route`, `query`, `body`, `headers`, `ip`, `user_agent`, `user`.
- `response` — toggle capture of `status`, `duration`, and (for JSON responses) `content`.
- `except_body` / `except_headers` — keys/headers whose values are replaced with `redacted` (default `[REDACTED]`); body keys are matched recursively.
- `max_content_length` — truncate captured bodies/response content beyond this many characters (`null` disables).
- `user_fields` — fields captured for the authenticated user; each is a model attribute name or a callable receiving the user.

Per-request control
-------------------

[](#per-request-control)

The `LogBarrel` facade lets you tailor — or switch off — logging for the current request from anywhere in the request lifecycle (a controller, form request, action, event listener…). Because the entry is written after the response is produced, anything you set is picked up when it matters. State is reset at the start of every request, so it never leaks to the next one.

```
use Mxnwire\LogBarrel\Facades\LogBarrel;

class CheckoutController
{
    public function store(Request $request)
    {
        // Don't log this request at all.
        LogBarrel::disable();

        // ...or force-log it even when globally off / outside the configured groups.
        LogBarrel::enable();

        // Attach extra context to the entry.
        LogBarrel::context(['order_id' => $order->id]);

        // Redact extra body keys on top of the configured list.
        LogBarrel::redact('ssn');                 // or ['ssn', 'card_number']

        // Capture only specific fields, or drop specific ones.
        LogBarrel::only('method', 'url', 'user'); // whitelist
        LogBarrel::without('body');               // blacklist

        // Send this request's entry to a different channel / message.
        LogBarrel::channel('audit')->message('checkout_completed');
    }
}
```

All methods are chainable and resolve the shared singleton, so `LogBarrel::context([...])->redact('ssn')->channel('audit')` works as expected.

Prefer a helper over the facade? `logbarrel()` returns the same singleton:

```
logbarrel()->disable();
logbarrel()->context(['order_id' => $order->id])->channel('audit');
```

### Manual middleware registration

[](#manual-middleware-registration)

Set `register_global_middleware` to `false`, then apply the alias where needed:

```
Route::middleware('logbarrel')->group(function () {
    // ...
});
```

Testing
-------

[](#testing)

```
composer install
composer test
```

License
-------

[](#license)

MIT.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance90

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/45322767?v=4)[mhxnahid](/maintainers/mhxnahid)[@mhxnahid](https://github.com/mhxnahid)

---

Top Contributors

[![mhxnahid](https://avatars.githubusercontent.com/u/45322767?v=4)](https://github.com/mhxnahid "mhxnahid (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mxnwire-laravel-logbarrel/health.svg)

```
[![Health](https://phpackages.com/badges/mxnwire-laravel-logbarrel/health.svg)](https://phpackages.com/packages/mxnwire-laravel-logbarrel)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M348](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)

PHPackages © 2026

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