pushHandler(new StreamHandler($logFilePath), $level); $logger->pushProcessor(new WebProcessor()); switch($level) { case Logger::INFO: $logger->addInfo($content, $extra); break; case Logger::ERROR: $logger->addError($content, $extra); break; default: $logger->addInfo($content, $extra); break; } } catch (\Exception $e) { $exceptionLogPath = storage_path('logs/exception/monolog.log'); file_put_contents($exceptionLogPath, date('Y-m-d H:i:s') . " " . $e->getMessage() . "\r\n", FILE_APPEND); } } /** * 信息日志 * @param $title * @param $content * @param string $file */ public static function logInfo($content, $extra=array(), $prefix='info') { self::log($prefix, $content, $extra, Logger::INFO); } /** * 错误日志 * @param $title * @param $content * @param string $file */ public static function logError($content, $extra=array(), $prefix='error') { self::log($prefix, $content, $extra, Logger::ERROR); } }