friendsofhyperf/access-log

Access log component for hyperf.

0.1.1 2021-09-01 08:23 UTC

This package is auto-updated.

Last update: 2021-11-07 04:47:48 UTC


README

Latest Stable Version Total Downloads GitHub license

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',
    ],
];