diff --git a/convention.php b/convention.php index 4bde7d88..4ca03c06 100644 --- a/convention.php +++ b/convention.php @@ -155,6 +155,8 @@ return [ 'show_error_msg' => false, // 异常处理handle类 留空使用 \think\exception\Handle 'exception_handle' => '', + // 是否记录trace信息到日志 + 'record_trace' => false, // +---------------------------------------------------------------------- // | 日志设置 diff --git a/library/think/exception/Handle.php b/library/think/exception/Handle.php index 8b6e6c40..d975690e 100644 --- a/library/think/exception/Handle.php +++ b/library/think/exception/Handle.php @@ -52,6 +52,10 @@ class Handle $log = "[{$data['code']}]{$data['message']}"; } + if (Config::get('record_trace')) { + $log .= "\r\n" . $exception->getTraceAsString(); + } + Log::record($log, 'error'); } }