定时清理日志
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.nl.modules.logging.aspect;
|
package org.nl.modules.logging.aspect;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -128,7 +129,7 @@ public class LogAspect {
|
|||||||
json.put("address", StringUtils.getCityInfo(requestIp));
|
json.put("address", StringUtils.getCityInfo(requestIp));
|
||||||
json.put("browser", StringUtils.getBrowser(request));
|
json.put("browser", StringUtils.getBrowser(request));
|
||||||
json.put("exception_detail", IdUtil.getStringId());
|
json.put("exception_detail", IdUtil.getStringId());
|
||||||
json.put("create_time", IdUtil.getStringId());
|
json.put("create_time", DateUtil.now());
|
||||||
json.put("return_result", JSONObject.fromObject(result).getJSONObject("body"));
|
json.put("return_result", JSONObject.fromObject(result).getJSONObject("body"));
|
||||||
interfaceLog.insert(json);
|
interfaceLog.insert(json);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import org.nl.modules.wql.core.bean.WQLObject;
|
|||||||
import org.nl.system.service.param.ISysParamService;
|
import org.nl.system.service.param.ISysParamService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动清除日志(操作日志、异常日志)数据
|
* 自动清除日志(操作日志、异常日志)数据
|
||||||
*/
|
*/
|
||||||
@@ -18,8 +20,11 @@ public class CleanLog {
|
|||||||
public void run(){
|
public void run(){
|
||||||
//delete from sys_log where DATE(create_time) <= DATE(DATE_SUB(NOW(),INTERVAL 30 day)) limit 10;
|
//delete from sys_log where DATE(create_time) <= DATE(DATE_SUB(NOW(),INTERVAL 30 day)) limit 10;
|
||||||
WQLObject logTab = WQLObject.getWQLObject("sys_log");
|
WQLObject logTab = WQLObject.getWQLObject("sys_log");
|
||||||
|
WQLObject sys_interface_log = WQLObject.getWQLObject("sys_interface_log");
|
||||||
int days = Integer.parseInt(paramService.findByCode("log_day").getValue());
|
int days = Integer.parseInt(paramService.findByCode("log_day").getValue());
|
||||||
logTab.delete("DATE(create_time) <= DATE(DATE_SUB(NOW(),INTERVAL " + days + " day))");
|
logTab.delete("DATE(create_time) <= DATE(DATE_SUB(NOW(),INTERVAL " + days + " day))");
|
||||||
|
sys_interface_log.delete("DATE(create_time) <= DATE(DATE_SUB(NOW(),INTERVAL " + days + " day))");
|
||||||
|
|
||||||
log.info("自动清理日志执行成功...!");
|
log.info("自动清理日志执行成功...!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user