- 后端:增加异常日志的记录

This commit is contained in:
YunaiV
2019-05-11 02:46:34 +08:00
parent 25ecc25139
commit 6697f4f723
13 changed files with 331 additions and 89 deletions

View File

@@ -1,6 +1,7 @@
package cn.iocoder.mall.admin.api;
import cn.iocoder.mall.admin.api.dto.AccessLogAddDTO;
import cn.iocoder.mall.admin.api.dto.ExceptionLogAddDTO;
/**
* 系统日志 Service 接口
@@ -11,4 +12,6 @@ public interface SystemLogService {
void addAccessLog(AccessLogAddDTO accessLogAddDTO);
void addExceptionLog(ExceptionLogAddDTO exceptionLogAddDTO);
}

View File

@@ -1,7 +1,6 @@
package cn.iocoder.mall.admin.api.dto;
import cn.iocoder.common.framework.vo.CommonResult;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -20,78 +19,33 @@ public class AccessLogAddDTO implements Serializable {
* 用户编号 - 空
*/
public static final Integer USER_ID_NULL = 0;
/**
* 链路追踪编号
*
* 一般来说通过链路追踪编号可以将访问日志错误日志链路追踪日志logger 打印日志等,结合在一起,从而进行排错。
*/
@NotNull(message = "链路追踪编号不能为空")
private String traceId;
/**
* 用户编号.
*
* 当管理员为空时,该值为 {@link #USER_ID_NULL}
*/
@NotNull(message = "用户编号不能为空")
private Integer userId;
/**
* 用户类型
*/
@NotNull(message = "用户类型不能为空")
private Integer userType;
/**
* 应用名
*
* 目前读取 spring.application.name
*/
@NotNull(message = "应用名不能为空")
private String applicationName;
/**
* 访问地址
*/
@NotNull(message = "访问地址不能为空")
private String uri;
/**
* 参数
*/
@NotNull(message = "请求参数不能为空")
private String queryString;
/**
* http 方法
*/
@NotNull(message = "http 请求方法不能为空")
private String method;
/**
* User Agent
*/
@NotNull(message = "User-Agent 不能为空")
private String userAgent;
/**
* ip
*/
@NotNull(message = "ip 不能为空")
private String ip;
/**
* 请求时间
*/
@NotNull(message = "请求时间不能为空")
private Date startTime;
/**
* 响应时长 -- 毫秒级
*/
@NotNull(message = "响应时长不能为空")
private Integer responseTime;
/**
* 错误码
*
* 目前的结果,是使用 {@link CommonResult#getCode()} 属性
*/
@NotNull(message = "错误码不能为空")
private Integer errorCode;
/**
* 错误提示
*
* 目前的结果,是使用 {@link CommonResult#getMessage()} 属性
*/
private String errorMessage;

View File

@@ -0,0 +1,58 @@
package cn.iocoder.mall.admin.api.dto;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 异常日志添加 DTO
*/
@Data
@Accessors(chain = true)
public class ExceptionLogAddDTO {
/**
* 用户编号 - 空
*/
public static final Integer USER_ID_NULL = 0;
@NotNull(message = "链路追踪编号不能为空")
private String traceId;
@NotNull(message = "用户编号不能为空")
private Integer userId;
@NotNull(message = "用户类型不能为空")
private Integer userType;
@NotNull(message = "应用名不能为空")
private String applicationName;
@NotNull(message = "访问地址不能为空")
private String uri;
@NotNull(message = "请求参数不能为空")
private String queryString;
@NotNull(message = "http 请求方法不能为空")
private String method;
@NotNull(message = "User-Agent 不能为空")
private String userAgent;
@NotNull(message = "ip 不能为空")
private String ip;
@NotNull(message = "异常时间不能为空")
private Date exceptionTime;
@NotNull(message = "异常名不能为空")
private String exceptionName;
@NotNull(message = "异常发生的类全名不能为空")
private String exceptionClassName;
@NotNull(message = "异常发生的类文件不能为空")
private String exceptionFileName;
@NotNull(message = "异常发生的方法名不能为空")
private String exceptionMethodName;
@NotNull(message = "异常发生的方法所在行不能为空")
private Integer exceptionLineNumber;
@NotNull(message = "异常的栈轨迹不能为空")
private String exceptionStackTrace;
@NotNull(message = "异常导致的根消息不能为空")
private String exceptionRootCauseMessage;
@NotNull(message = "异常导致的消息不能为空")
private String exceptionMessage;
}