rev:操作日志问题修改
This commit is contained in:
@@ -148,9 +148,9 @@ public class StringUtils {
|
||||
*/
|
||||
public static String getIp(HttpServletRequest request) {
|
||||
// TODO 不解析IP地址
|
||||
if(true){
|
||||
return "127.0.0.1";
|
||||
}
|
||||
// if(true){
|
||||
// return "127.0.0.1";
|
||||
// }
|
||||
|
||||
String ip = request.getHeader("x-forwarded-for");
|
||||
if (ip == null || ip.length() == 0 || UNKNOWN.equalsIgnoreCase(ip)) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.nl.common.utils.IdUtil;
|
||||
import org.nl.modules.common.utils.RequestHolder;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.utils.StringUtils;
|
||||
import org.nl.modules.common.utils.ThrowableUtil;
|
||||
import org.nl.modules.logging.domain.Log;
|
||||
@@ -93,7 +94,7 @@ public class LogAspect {
|
||||
//是否把日志存到日志表
|
||||
if (logInfo.isAddLogTable()) {
|
||||
Log log = new Log("INFO", System.currentTimeMillis() - startTime);
|
||||
logService.save("", StringUtils.getBrowser(request), requestIp, joinPoint, log);
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), requestIp, joinPoint, log);
|
||||
}
|
||||
if (logInfo.isInterfaceLog()) {
|
||||
try {
|
||||
@@ -122,7 +123,7 @@ public class LogAspect {
|
||||
log.error("track_id:{},error:{}", trackId, ex.getMessage());
|
||||
Log log = new Log("ERROR", System.currentTimeMillis() - startTime);
|
||||
log.setExceptionDetail(ThrowableUtil.getStackTrace(ex).getBytes());
|
||||
logService.save("", StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint) joinPoint, log);
|
||||
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint) joinPoint, log);
|
||||
throw ex;
|
||||
}
|
||||
return result;
|
||||
@@ -158,11 +159,11 @@ public class LogAspect {
|
||||
return argList.size() == 1 ? JSONUtil.toJsonStr(argList.get(0)) : JSONUtil.toJsonStr(argList);
|
||||
}
|
||||
|
||||
// public String getUsername() {
|
||||
// try {
|
||||
// return SecurityUtils.getCurrentUsername();
|
||||
// } catch (Exception e) {
|
||||
// return "";
|
||||
// }
|
||||
// }
|
||||
public String getUsername() {
|
||||
try {
|
||||
return SecurityUtils.getCurrentUsername();
|
||||
} catch (Exception e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user