New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

josrom/laravel-logger

ChannelLog: Custom logger to laravel
3,114
Install
composer require josrom/laravel-logger
Latest Version:13.0.0
PHP:^8.3
Laravel:13
Older releases:4 · 5 · 8 – 12
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.

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

Related Packages

oilstone/logging

A PSR\Log wrapper for handling static log classes that can be enabled/disabled o...

8,324 2
tokenly/fluentd-logger

A Fluentd logging component for Laravel

20,192 2
minvws/laravel-logging

Laravel provider for logging functionality

7,237 1
coolonce/logger-interface

This package allows you to send data for logging to the HTTP daemon associated w...

4,640 1
imer/laravel-query-table

Laravel plugin for displaying query results as a table with built-in filtering/s...

2,076 0

Version History

Version Released PHP Laravel License
13.0.0 ^8.3 13.* MIT
12.0.0 ^8.2 12.* MIT
11.0.0 ^8.1 11.* MIT
10.0.0 ^8.0 10.* MIT
9.0.0 ^8.0 9.* MIT