PHPackages                             natural-cloud/logger-php - 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. natural-cloud/logger-php

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

natural-cloud/logger-php
========================

quick into php framework

v0.2(3y ago)16MITPHPPHP &gt;=7.2

Since Feb 2Pushed 3y ago1 watchersCompare

[ Source](https://github.com/naturalCloud/logger-php)[ Packagist](https://packagist.org/packages/natural-cloud/logger-php)[ RSS](/packages/natural-cloud-logger-php/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

logger
======

[](#logger)

介绍
--

[](#介绍)

借鉴和迁移修改 `laravel` 和 `hyperf` 对 `monolog/monolog` 封装,尽量达到快速接入任一 `php` 框架

接入
--

[](#接入)

### easyswoole

[](#easyswoole)

#### 复制 `config` 到 `dev.php`

[](#复制-config-到-devphp)

```
storage_path = sys_get_temp_dir();
return [

    /*
    |--------------------------------------------------------------------------
    | Default Log Channel
    |--------------------------------------------------------------------------
    |
    | This option defines the default log channel that gets used when writing
    | messages to the logs. The name specified in this option should match
    | one of the channels defined in the "channels" configuration array.
    |
    */
    // 'default' => env('LOG_CHANNEL', 'stack'),
    'default' => 'stack',

    'storage_path' => $storage_path,// 日志主目录,

    /*
    |--------------------------------------------------------------------------
    | Deprecations Log Channel
    |--------------------------------------------------------------------------
    |
    | This option controls the log channel that should be used to log warnings
    | regarding deprecated PHP and library features. This allows you to get
    | your application ready for upcoming major versions of dependencies.
    |
    */

    'deprecations' => 'LOG_DEPRECATIONS_CHANNEL',

    /*
    |--------------------------------------------------------------------------
    | Log Channels
    |--------------------------------------------------------------------------
    |
    | Here you may configure the log channels for your application. Out of
    | the box, Laravel uses the Monolog PHP logging library. This gives
    | you a variety of powerful log handlers / formatters to utilize.
    |
    | Available Drivers: "single", "daily", "slack", "syslog",
    |                    "errorlog", "monolog",
    |                    "custom", "stack"
    |
    */

    'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['single'],
            'ignore_exceptions' => false,
        ],

        'single' => [
            'driver' => 'single',
            'path' => 'single.log', // 日志文件路径 ,绝对路径, storage_path 设置可设置相对路径
            'level' => 'debug',
        ],

        'daily' => [
            'driver' => 'daily',
            'path' => 'daily.log', // 日志文件路径 ,绝对路径,  storage_path 设置可设置相对路径
            'level' => 'debug',
            'days' => 14,
        ],
        'syslog' => [
            'driver' => 'syslog',
            'level' => 'debug',
        ],

        'errorlog' => [
            'driver' => 'errorlog',
            'level' => 'debug',
        ],

        'emergency' => [
            'driver' => 'single',
            'path' => 'emergency.log', // 日志文件路径 ,绝对路径,  storage_path 设置可设置相对路径
        ],
        // 终端打印日志
        'console' => [
            'name' => 'console', // 显示的名字
            'driver' => 'monolog',
            'level' => 'debug',
            'handler' => StreamHandler::class,
            'formatter' => \NaturalCloud\Logger\Formatter\ConsoleColorFormatter::class,
            'with' => [
                // handler 参数
                'stream' => STDOUT,
            ],
            'formatter_with' => [ // formatter 的构造函数参数
                'dateFormat' => 'Y-m-d H:i:s'
            ],
            'tap' => [\NaturalCloud\Logger\Tap\TapFormatter::class]
        ],
        'json' => [
            'driver' => 'monolog',
            'level' => 'debug',
            'handler' => StreamHandler::class,
            'with' => [ // handler 参数
                'stream' => $storage_path . '/json.log',
            ],
            'formatter' => \NaturalCloud\Logger\Formatter\JsonFormatter::class,
            'formatter_with' => [ // formatter 的构造函数参数
                'dateFormat' => 'Y-m-d H:i:s'
            ],
            'tap' => [\NaturalCloud\Logger\Tap\TapFormatter::class]
        ]
    ],

];
```

#### 注入 `Di` 容器

[](#注入-di-容器)

```
$loggerConfig = [];
\NaturalCloud\Logger\Framework\Easyswoole::setLogger($loggerConfig,'logger-new')
```

#### 获取 `logger`

[](#获取-logger)

```
$logger = \NaturalCloud\Logger\Framework\Easyswoole::getLogger('logger-new');
// 写到默认 chanel
$logger->info('aaaa');
$logger->warning('bbbb');
// 打印到终端 info 级别
$logger->channel('console')->info('in console');
// 快速自定义配置logger ，用于动态的写入不同文件名的logger
// 写入 日志主目录/swoole.log
$logger->channelFile('swoole');
```

#### 设置 `traceId`

[](#设置-traceid)

```
\NaturalCloud\Logger\Framework\Easyswoole::trace($request,$response,'x-request-id',function (){
return \NaturalCloud\Logger\Support\Str::random('36')
});
```

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

1247d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9886640e67efa0f5df3a8a8d04a5a24f019d4f95d9fb6fc726678a30fa34f4df?d=identicon)[naturalCloud](/maintainers/naturalCloud)

---

Top Contributors

[![naturalCloud](https://avatars.githubusercontent.com/u/30367263?v=4)](https://github.com/naturalCloud "naturalCloud (2 commits)")

---

Tags

phplaravelloggerhyperf

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/natural-cloud-logger-php/health.svg)

```
[![Health](https://phpackages.com/badges/natural-cloud-logger-php/health.svg)](https://phpackages.com/packages/natural-cloud-logger-php)
```

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[illuminate/log

The Illuminate Log package.

6225.3M622](/packages/illuminate-log)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k16.4k79](/packages/elgg-elgg)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

85036.3k](/packages/flow-php-flow)

PHPackages © 2026

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