AutoCleanMonitorLogJob.java
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.ecar.apm.job;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import com.ecar.apm.service.HttpRequestService;
@Component
public class AutoCleanMonitorLogJob implements InitializingBean {
private static final Logger LOG = LoggerFactory.getLogger(AutoCleanMonitorLogJob.class);
@Autowired
private transient HttpRequestService logService;
public AutoCleanMonitorLogJob() {
}
@Value("${auto.clean.monitor.log.keep.day}")
private int day;
@Scheduled(cron = "${auto.clean.monitor.log.cron.expression}")
public void execute() {
LOG.debug("***** Start execute Job [{}]", getClass());
logService.cleanMonitorLogs(day);
LOG.debug("&&&&& End execute Job [{}]", getClass());
}
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(logService, "logService is null");
}
}