解决命令行和fastcgi不同环境下生成的日志导致的权限问题


# Laravel: AppServiceProvider.
public function boot()
{
    if (PHP_SAPI == 'cli') {
        Log::useDailyFiles(storage_path('logs/artisan.log'), config('app.log_max_files', 5));
    }
}


# Lumen: /bootstrap/app.php
$app->configureMonologUsing(function(Monolog\Logger $monolog) {
    $filename = storage_path('logs/lumen-'.PHP_SAPI.'.log');
   
    $handler = new Monolog\Handler\RotatingFileHandler($filename, env('LOG_MAX_FILES', 5));
   
    $handler->setFormatter(new Monolog\Formatter\LineFormatter(null, null, true, true));
   
    $monolog->pushHandler($handler);
});