hzanchu / laravel_log
Laravel Log Monitor
1.5.1
2023-07-05 09:32 UTC
Requires
- hzanchu/restful: ^1.0
This package is not auto-updated.
Last update: 2024-11-06 15:56:13 UTC
README
开发目的:监控Laravel系统中的请求信息,报错、超时等情况。
1. 使用说明
1.1 下载依赖
composer require hzanchu/laravel_log
1.2 注册中间件
app/Http/Kernel.php
:
protected $middlewareGroups = [
'api' => [
Anchu\LaravelLog\Middlewares\LogRequest::class,
],
];
1.3 注入代码
捕获错误信息:app/Exceptions/Handler.php
public function register()
{
$this->reportable(function (Throwable $e) {
// 捕获异常到临时变量
$_COOKIE['exception'] = json_encode([
'code' => $exception->getCode(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'message' => $exception->getMessage()
]);
});
}
1.4 配置参数
在多个数据库的情况下,需要如下参数指定链接:
.env
:
MONITOR_DB_CONNECTION=mysql
LOG_TOKEN=xxxx