1
This commit is contained in:
@@ -27,6 +27,7 @@ import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.nl.common.utils.BaseCode;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.utils.RequestHolder;
|
||||
@@ -67,7 +68,7 @@ public class LogAspect {
|
||||
*/
|
||||
@Around("@annotation(logInfo)")
|
||||
public Object logAround(ProceedingJoinPoint joinPoint,org.nl.modules.logging.annotation.Log logInfo) throws Throwable {
|
||||
String trackId = UUID.randomUUID().toString();
|
||||
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
String methodName = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()";
|
||||
@@ -77,7 +78,7 @@ public class LogAspect {
|
||||
|
||||
MDC.put("requestMethod",methodName);
|
||||
MDC.put("requestIp", StringUtils.getIp(request));
|
||||
MDC.put("trackId", UUID.randomUUID().toString());
|
||||
MDC.put("traceId", BaseCode.intToChars(IdUtil.getLongId()));
|
||||
MDC.put("requestTime", DateUtil.now());
|
||||
|
||||
Object result = null;
|
||||
@@ -109,20 +110,19 @@ public class LogAspect {
|
||||
json.put("create_time", DateUtil.now());
|
||||
Object parse = JSONObject.parse(result.toString());
|
||||
json.put("return_result", parse);
|
||||
log.info("请求结果:{}",parse);
|
||||
interfaceLog.insert(json);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
}catch (Exception ex){
|
||||
log.info("[--requestError--][请求方法:{}]【异常信息 :{}】", methodName, ex);
|
||||
log.error("[--requestError--][请求方法:{}][请求参数:{}]【异常信息 :{}】", methodName,params, ex);
|
||||
Log log = new Log("ERROR", System.currentTimeMillis() - comming);
|
||||
log.setExceptionDetail(ThrowableUtil.getStackTrace(ex).getBytes());
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint) joinPoint, log);
|
||||
throw ex;
|
||||
}finally {
|
||||
log.info("[--response--][请求方法:{}][请求参数:{}]【返回结果 :{}】",methodName,params,result);
|
||||
log.info("[--response--][请求方法:{}][请求参数:{}],请求执行结束",methodName,params);
|
||||
MDC.clear();
|
||||
}
|
||||
return result;
|
||||
@@ -165,4 +165,7 @@ public class LogAspect {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class LogQuery {
|
||||
/**
|
||||
* 追踪id
|
||||
*/
|
||||
private String trackId;
|
||||
private String traceId;
|
||||
/**
|
||||
* 日志内容模糊匹配
|
||||
*/
|
||||
|
||||
@@ -20,8 +20,9 @@ public class LogRepositoryDTO {
|
||||
private String requestIp;
|
||||
@Id
|
||||
private String id;
|
||||
private String trackId;
|
||||
private String traceId;
|
||||
private String requestMethod;
|
||||
private String thread;
|
||||
private String system;
|
||||
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ public class EsLogServiceImpl implements EsLogService {
|
||||
if (logQuery.getFilterSql()){
|
||||
query.mustNot().add(QueryBuilders.wildcardQuery("logger","org.nl.modules.wql.core.engine.*"));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(logQuery.getTrackId())){
|
||||
query.must().add(QueryBuilders.matchQuery("trackId", logQuery.getTrackId()));
|
||||
if (StringUtils.isNotEmpty(logQuery.getTraceId())){
|
||||
query.must().add(QueryBuilders.matchQuery("traceId", logQuery.getTraceId()));
|
||||
}
|
||||
if (StringUtils.isNotEmpty(logQuery.getMessage())){
|
||||
query.must().add(QueryBuilders.matchQuery("message", logQuery.getMessage()).minimumShouldMatch("50%"));
|
||||
|
||||
Reference in New Issue
Block a user