tao.mo

common-dependencies | 修改 |

日志输出调整
mt
2025年4月1日18:44:30
...@@ -3,16 +3,19 @@ package com.fedex.connect.common.dependencies.config; ...@@ -3,16 +3,19 @@ package com.fedex.connect.common.dependencies.config;
3 import com.fedex.connect.common.dependencies.date.vo.ResponseVo; 3 import com.fedex.connect.common.dependencies.date.vo.ResponseVo;
4 import com.fedex.connect.common.dependencies.exception.BaseException; 4 import com.fedex.connect.common.dependencies.exception.BaseException;
5 import com.fedex.connect.common.dependencies.exception.OpErrorException; 5 import com.fedex.connect.common.dependencies.exception.OpErrorException;
6 +import lombok.extern.slf4j.Slf4j;
6 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; 7 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
7 import org.springframework.web.bind.annotation.ExceptionHandler; 8 import org.springframework.web.bind.annotation.ExceptionHandler;
8 import org.springframework.web.bind.annotation.RestControllerAdvice; 9 import org.springframework.web.bind.annotation.RestControllerAdvice;
9 10
11 +@Slf4j
10 @ConditionalOnProperty(prefix = "common.exception-advice-webconfig", name = "enable", havingValue = "true") 12 @ConditionalOnProperty(prefix = "common.exception-advice-webconfig", name = "enable", havingValue = "true")
11 @RestControllerAdvice 13 @RestControllerAdvice
12 public class ControllerExceptionAdvice { 14 public class ControllerExceptionAdvice {
13 15
14 @ExceptionHandler(Exception.class) 16 @ExceptionHandler(Exception.class)
15 public ResponseVo exceptionHandler(Exception ex) { 17 public ResponseVo exceptionHandler(Exception ex) {
18 + log.error(ex.getMessage(),ex);
16 ResponseVo res = new ResponseVo(); 19 ResponseVo res = new ResponseVo();
17 res.setSuccess(false); 20 res.setSuccess(false);
18 res.setCode(599); 21 res.setCode(599);
...@@ -22,6 +25,7 @@ public class ControllerExceptionAdvice { ...@@ -22,6 +25,7 @@ public class ControllerExceptionAdvice {
22 25
23 @ExceptionHandler(BaseException.class) 26 @ExceptionHandler(BaseException.class)
24 public ResponseVo baseExceptionHandler(BaseException ex) { 27 public ResponseVo baseExceptionHandler(BaseException ex) {
28 + log.error(ex.getMessage(),ex);
25 ResponseVo res = new ResponseVo(); 29 ResponseVo res = new ResponseVo();
26 res.setSuccess(false); 30 res.setSuccess(false);
27 res.setCode(ex.getCode().intValue()); 31 res.setCode(ex.getCode().intValue());
...@@ -31,6 +35,7 @@ public class ControllerExceptionAdvice { ...@@ -31,6 +35,7 @@ public class ControllerExceptionAdvice {
31 35
32 @ExceptionHandler(OpErrorException.class) 36 @ExceptionHandler(OpErrorException.class)
33 public ResponseVo opErrorExceptionHandler(OpErrorException ex) { 37 public ResponseVo opErrorExceptionHandler(OpErrorException ex) {
38 + log.error(ex.getMessage(),ex);
34 ResponseVo res = new ResponseVo(); 39 ResponseVo res = new ResponseVo();
35 res.setSuccess(false); 40 res.setSuccess(false);
36 res.setCode(ex.getCode()); 41 res.setCode(ex.getCode());
......