$value) { $logDir = $logPath.'/'.$key; if (!file_exists($logDir)) mkdir($logDir , 0777 , true); self::logEnd($value, $logDir); } self::$logArr = null; }catch (\Exception $e){ return; } } public static function logEnd($data, $logDir) { foreach ($data as $k => $v) { //获取日志文件名 避免单个日志文件太大 $count = 1; while(true) { //生成日志文件名 $logFile = "{$logDir}".'/'."{$k}_{$count}.log"; //第一次写入日志 if (!is_file($logFile)) break; //日志文件未大于1M $file = filesize($logFile) / 1024; if ($file < 1024 * 100) break; $count++; } $v = rtrim($v); $v .= PHP_EOL.'================ End ================'.PHP_EOL.PHP_EOL; error_log($v, 3, $logFile); // $ch = fopen($logFile, 'ab'); // fwrite($ch, $v); // fclose($ch); } } /** * 日志黑名单 * @return array */ public static function whiteLog() { return array( // 'Framework/PassportController_login', ); } }