PHPackages                             nickfan/channel-log - 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. nickfan/channel-log

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

nickfan/channel-log
===================

Support Laravel Log data to separate channel log files with config

1118.9k↓73.7%1PHP

Since Sep 5Pushed 7y ago1 watchersCompare

[ Source](https://github.com/nickfan/ChannelLog)[ Packagist](https://packagist.org/packages/nickfan/channel-log)[ RSS](/packages/nickfan-channel-log/feed)WikiDiscussions develop Synced 2d ago

READMEChangelogDependenciesVersions (2)Used By (0)

ChannelLog
==========

[](#channellog)

[README in Chinese | 中文说明](README.zh-CN.md)

Intro
-----

[](#intro)

Support Laravel Log data to separate channel log files with config.

this project base on [ShQ's answer for laravel 5.2 custom log file for different tasks](http://stackoverflow.com/questions/37809989/laravel-5-2-custom-log-file-for-different-tasks)

Install
-------

[](#install)

- install composer package

```
composer require "nickfan/channel-log:dev-master"

```

- Edit config/app.php file

**providers group add:**

```
Nickfan\ChannelLog\ChannelLogServiceProvider::class,

```

**aliases group add:**

```
'ChannelLog' => Nickfan\ChannelLog\Facades\ChannelLog::class,

```

- publish config file:

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

```

Setup
-----

[](#setup)

```
return [
    'default' => [
        'path' => 'logs/default.log',
        'level' => \Monolog\Logger::DEBUG
    ],
//    'event' => [
//        'path' => 'logs/event.log',
//        'level' => \Monolog\Logger::INFO
//    ],
    'custom'=>[  // Channel Label Name
        'name'=>'custom',           // (optional) Channel Label Name
        'log'=>'daily',             // log mode support: console (only in stdout); single (single file); daily (daily files); syslog (syslog); errorlog (php errorlog);
        'console'=>true,            // output to stdout(console) at the sametime.
        'path'=>'logs/custom.log', // Log file path,relative path will convert to relative with storage_path(yourpath)
        'level' => \Monolog\Logger::DEBUG, // Log Level
        'log_syslog_name'=>'channel_log',   // syslog mode log entry name
        'log_max_files'=>5,                 // max files keep in daily log mode
        'formatter'=>\Nickfan\ChannelLog\ChannelLogJsonFormatter::class,           // (optional) Record Formatter Class Name
    ],
];

```

Custom Configurator
-------------------

[](#custom-configurator)

in a channel settings your could set your custom configurator by set a key name: `configurator`

the Configurator Class Must implements `Nickfan\ChannelLog\ChannelLogConfigurator ` interface

you could write your own configurator reference `Nickfan\ChannelLog\ChannelLogDefaultConfigurator` the default configurator class

config example:

```
return [
    'myconsole' => [  // Channel Label Name
        'path' => 'logs/default.log', // Log file path,relative path will convert to relative with storage_path(yourpath)
        'level' => \Monolog\Logger::DEBUG // Log Level
        // set the configurator class name
        'configurator' => \App\Support\ChannelLogMyConsoleConfigurator::class
    ],

];

```

Laravel Usage
-------------

[](#laravel-usage)

```

// Log to 'default' channel
ChannelLog::channel('default')->info('my test message {mykey1}',['mykey1'=>'myval1','aaa'=>'abc']);

// Log to 'event' channel
ChannelLog::channel('event')->error('my event message {mykey2}',['mykey2'=>'myval2','qqq'=>'qwe']);

// Log to 'mycustom' channel in daily log mode ,with filepath '/tmp/mycustom-2017-10-24.log'
ChannelLog::daily('/tmp/mycustom.log')->debug('my custom message {mykey2}',['mykey2'=>'myval2','qqq'=>'qwe']);

// Log to 'newdirect' channel in single log mode ,with filepath '/tmp/newdirect.log' , also log to console(stdout)
ChannelLog::direct([
            'name'=>'newdirect',// Channel Label Name
            'console'=>true,    // output to console(stdout)
            'path'=>'/tmp/newdirect.log', // log filepath
            ])->debug('new direct message {mykey2}',['mykey2'=>'myval2','qqq'=>'qwe']);

```

Standalone Usage
----------------

[](#standalone-usage)

```
use Nickfan\ChannelLog\ChannelLogWriterStandAlone;

$projectRoot = dirname(__DIR__);
$channelLogWriter = new ChannelLogWriterStandAlone(
  [
      'default'=>[
          'log' => 'single',
          'console'=> false,
          'path'=>$projectRoot.'/logs/default.log',
          'level'=>\Monolog\Logger::INFO,
      ],
      'event' => [
          'log' => 'daily',
          'console'=> true,
          'path' => $projectRoot.'/logs/event.log',
          'level' => \Monolog\Logger::DEBUG,
      ],
  ]
);

$channelLogWriter->channel('default')->info('my test message {mykey1}',['mykey1'=>'myval1','aaa'=>'abc']);

$result2 = $channelLogWriter->channel('event')->error('my event message {mykey2}',['mykey2'=>'myval2','qqq'=>'qwe']);

$result3 = $channelLogWriter->daily($projectRoot.'/logs/mycustom.log')->debug('my custom message {mykey2}',['mykey2'=>'myval2','qqq'=>'qwe']);

$result4 = $channelLogWriter->direct($projectRoot.'/logs/mydirect.log')->debug('my direct message {mykey2}',['mykey2'=>'myval2','qqq'=>'qwe']);

$result5 = $channelLogWriter->direct([
            'name'=>'newdirect',
            'console'=>true,
            'path'=>$projectRoot.'/logs/newdirect.log',
            ])->debug('new direct message {mykey2}',['mykey2'=>'myval2','qqq'=>'qwe']);

```

**more detail usage reference monolog offical site **

Support on Beerpay
------------------

[](#support-on-beerpay)

Hey dude! Help me out for a couple of 🍻!

[![Beerpay](https://camo.githubusercontent.com/a1a8643a3d6b69e9f1ef983fadcfe5d929110e82ed0cccd035cdbf13c925c03d/68747470733a2f2f626565727061792e696f2f6e69636b66616e2f4368616e6e656c4c6f672f62616467652e7376673f7374796c653d626565722d737175617265)](https://beerpay.io/nickfan/ChannelLog) [![Beerpay](https://camo.githubusercontent.com/4b0aefe14456b2f0ced49ac7f9a7caba94584daa303426d2b857a7f5ce157ced/68747470733a2f2f626565727061792e696f2f6e69636b66616e2f4368616e6e656c4c6f672f6d616b652d776973682e7376673f7374796c653d666c61742d737175617265)](https://beerpay.io/nickfan/ChannelLog?focus=wish)

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community8

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.

### Community

Maintainers

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

---

Top Contributors

[![nickfan](https://avatars.githubusercontent.com/u/100613?v=4)](https://github.com/nickfan "nickfan (27 commits)")

---

Tags

composerlaravelmonologphp

### Embed Badge

![Health badge](/badges/nickfan-channel-log/health.svg)

```
[![Health](https://phpackages.com/badges/nickfan-channel-log/health.svg)](https://phpackages.com/packages/nickfan-channel-log)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B11.5k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

1941.5M276](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2328.5M343](/packages/open-telemetry-sdk)

PHPackages © 2026

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