josrom/laravel-logger

ChannelLog: Custom logger to laravel
3,113
Install
composer require josrom/laravel-logger
Latest Version:13.0.0
PHP:^8.3
License:MIT
Last Updated:Aug 21, 2026
Links: GitHub  ·  Packagist
Maintainer: Josrom

ChannelLog

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.

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.*

Related Packages

bugsnag/bugsnag-laravel

Official Bugsnag notifier for Laravel applications.

37,358,129 902
rollbar/rollbar-laravel

Rollbar error monitoring integration for Laravel projects

11,278,101 140