|
@@ -80,30 +80,24 @@ public class GlobalExceptionHandler implements ResponseBodyAdvice<Object> {
|
|
|
|
|
|
// -- 自定义异常输出结构 ----------------------------------------------------
|
|
// -- 自定义异常输出结构 ----------------------------------------------------
|
|
public static void printException(Exception e, Boolean isPrintStack) {
|
|
public static void printException(Exception e, Boolean isPrintStack) {
|
|
-
|
|
|
|
- log.error("-------------------------------------------------------------------------------");
|
|
|
|
- System.out.println("--------------------------------------------------");
|
|
|
|
-
|
|
|
|
|
|
+ log.error("========================================================================");
|
|
// 获取请求的URL
|
|
// 获取请求的URL
|
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
|
if (attributes != null) {
|
|
if (attributes != null) {
|
|
HttpServletRequest request = attributes.getRequest();
|
|
HttpServletRequest request = attributes.getRequest();
|
|
if (request != null) {
|
|
if (request != null) {
|
|
String url = request.getRequestURL().toString();
|
|
String url = request.getRequestURL().toString();
|
|
- log.error("Exception occurred in request: {}", url);
|
|
|
|
- System.out.println("Exception occurred in request: " + url);
|
|
|
|
|
|
+ log.error(url);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- // 记录异常消息
|
|
|
|
- log.error("Exception message: " + e.getMessage());
|
|
|
|
- // 记录当前异常类的class名称
|
|
|
|
- log.error("Exception class: {}", e.getClass().getName());
|
|
|
|
|
|
+ // 记录 当前异常类的class名称、异常消息
|
|
|
|
+ log.error(e.getMessage() + " (" + e.getClass().getName() + ")");
|
|
// 记录异常的详细信息
|
|
// 记录异常的详细信息
|
|
if (isPrintStack) {
|
|
if (isPrintStack) {
|
|
log.error(Convert.toStr(e.getStackTrace()));
|
|
log.error(Convert.toStr(e.getStackTrace()));
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
+ log.error("========================================================================");
|
|
}
|
|
}
|
|
public static void printException(Exception e) {
|
|
public static void printException(Exception e) {
|
|
printException(e, false);
|
|
printException(e, false);
|