Looking to hire Laravel developers? Try LaraJobs

laravel-api-log-middleware maintained by nosun

Description
Api Log Middleware for Laravel
Author
Last update
2020/11/02 10:10 (dev-master)
License
Links
Downloads
24

Comments
comments powered by Disqus

Installing

$ composer require nosun/laravel-api-log-middleware

Usage

  1. 引入中间件 App/Http/kernel.php
    $routeMiddleware = [
        ...
       'api_log' => Nosun\ApiLog::class,
    ]
  1. 设置单独的日志通道 config/logging.php
    'api' => [
        'driver' => 'single',
        'path' => storage_path('logs/api.log'),
        'level' => 'debug',
        'days' => 1,
    ]
  1. 创建配置文件 config/api-log.php
    <?php
    
    return [
        'enable' => env('API_LOG_ENABLE','false'),
    ];
  1. api_log 加入路由, 将 API_LOG_ENABLE=true 加入 .env

  2. 查看输出日志: "storage/logs/api.log"

Todo

  • 开发 console,使用 artisan 发布 config file。

Contributing

File bug reports using the issue tracker.

License

MIT