friendsofhyperf/access-log

The access log component for Hyperf.

v3.1.5 2023-12-20 04:25 UTC

README

Latest Stable Version Total Downloads License

The access log component for Hyperf.

Installation

  • Request
composer require friendsofhyperf/access-log
  • Publish
php bin/hyperf.php vendor:publish friendsofhyperf/access-log
  • Add logger group
// config/autoload/logger.php
return [
    // ...
    'access' => [
        'handler' => [
            'class' => \Monolog\Handler\StreamHandler::class,
            'constructor' => [
                'stream' => BASE_PATH . "/runtime/logs/access_log.log",
                'level' => Monolog\Logger::DEBUG,
            ],
        ],
        'formatter' => [
            'class' => \FriendsOfHyperf\AccessLog\Formatter\AccessLogFormatter::class,
        ],
    ],
];
  • Switch logger group
// config/autoload/access_log.php
return [
    'enable' => env('ACCESS_LOG_ENABLE', false),
    'logger' => [
        'group' => 'access',
        'time_format' => 'd/M/Y:H:i:s O',
    ],
    'ignore_user_agents' => [
        'Consul Health Check',
    ],
    'ignore_paths' => [
        '/favicon.ico',
    ],
];

Donate

If you like them, Buy me a cup of coffee. Alipay | WeChat

Contact

License

MIT