新增:新增系统监控/登录日志功能,优化日志表结构,并新增记录错误信息(非未知异常不记录异常详情,只记录错误信息)

This commit is contained in:
2023-01-17 23:16:37 +08:00
parent aa726fc6b6
commit c57383abad
28 changed files with 711 additions and 187 deletions

View File

@@ -57,4 +57,31 @@ public class LogContextHolder {
public static void remove() {
LOG_THREAD_LOCAL.remove();
}
/**
* 在系统日志上下文中保存异常信息
*
* @param e
* 异常信息
*/
public static void setException(Exception e) {
LogContext logContext = get();
if (logContext != null) {
logContext.setErrorMsg(e.getMessage());
logContext.setException(e);
}
}
/**
* 在系统日志上下文中保存错误信息(非未知异常不记录异常信息,只记录错误信息)
*
* @param errorMsg
* 错误信息
*/
public static void setErrorMsg(String errorMsg) {
LogContext logContext = get();
if (logContext != null) {
logContext.setErrorMsg(errorMsg);
}
}
}