josrom/laravel-logger

ChannelLog: Custom logger to laravel

Maintainers

Package info

github.com/JoseVte/laravel-logger

pkg:composer/josrom/laravel-logger

Transparency log

Statistics

Installs: 3 113

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

13.0.0 2026-08-21 09:40 UTC

README

ChannelLog lets you log to separate files per channel, each with its own minimum level, so you are not stuck with a single catch-all log.

Total Downloads Latest Stable Version License Tests Code Style

Contents

Requirements

  • PHP 8.3 or higher
  • Laravel 13.x

For older Laravel versions, check the supported versions table below.

Installation

Require the package with Composer:

composer require josrom/laravel-logger

Register the service provider and the facade alias in your config/app.php file:

'providers' => [
    // Other Service Providers

    Laravel\ChannelLog\ChannelLogServiceProvider::class,
],

'aliases' => [
    // Other Aliases

    'ChannelLog' => Laravel\ChannelLog\ChannelLog::class,
],

Then publish the config file:

php artisan vendor:publish --provider="Laravel\ChannelLog\ChannelLogServiceProvider"

This creates config/laravel-logger.php.

Configuration

Each key under channels defines a log channel: where it writes to, and its minimum level.

// config/laravel-logger.php

return [
    'channels' => [
        'event' => [
            'path' => 'logs/laravel-event.log',
            'level' => \Monolog\Level::Info,
        ],
        'error' => [
            'path' => 'logs/laravel-error.log',
            'level' => \Monolog\Level::Error,
        ],
        'info' => [
            'path' => 'logs/laravel-info.log',
            'level' => \Monolog\Level::Info,
            'extras' => ['internet-provider'],
        ],
    ],
];
  • path is relative to the storage directory.
  • level accepts any Monolog\Level case (Debug, Info, Notice, Warning, Error, Critical, Alert, Emergency).
  • extras is optional, see Extras.

Usage

Use the ChannelLog facade to write to a specific channel. The method name sets the log level:

use ChannelLog;

ChannelLog::info('event', 'A user logged in.');
ChannelLog::error('error', 'Something went wrong.', ['user_id' => $user->id]);

To write at the level already configured for a channel, use write():

ChannelLog::write('event', 'A user logged in.');

Arrays, and anything implementing Illuminate\Contracts\Support\Arrayable or Illuminate\Contracts\Support\Jsonable (such as Eloquent models and collections), are formatted automatically before being written:

ChannelLog::info('event', $user);
ChannelLog::info('event', ['user_id' => $user->id, 'action' => 'login']);

Extras

Extras add extra context to a channel's log entries.

  • internet-provider: looks up the requesting IP's internet provider through ipinfo.io and appends it as an additional log line.

Testing

The package uses Pest with Orchestra Testbench.

composer test

Check the code style with PHP CS Fixer:

composer format

Both run automatically on every push and pull request through GitHub Actions.

Supported versions

Package version Laravel version
13.* 13.*
12.* 12.*
11.* 11.*
10.* 10.*
9.* 9.*
8.* 8.*
7.* 7.*
6.* 6.*
0.1.* / 5.* 5.*