package fang.elk.log.main;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import fang.elk.log.printer.FTPLogPrinter;
import fang.elk.log.printer.WebLogPrinter;
import fang.elk.log.utility.RandomObjectUtil;
public class Main {
public static void main(String[] args) throws Exception {
// final String serverLogPath = "C:/Users/MF59756/workspace/logPrinter/serverLog/serverLog";
final String webLogPath = "F:/logSimulator/WebLogs/webLog";
final String ftpLogPath = "F:/logSimulator/FTPLogs/ftpLog";
final RandomObjectUtil randomObjectUtil =new RandomObjectUtil(null);
// 启动一个线程每1秒钟产生一个log对象
ScheduledExecutorService exec = Executors.newScheduledThreadPool(1);
exec.scheduleWithFixedDelay(new Runnable() {
public void run() {
try {
// ServerLogPrinter serverLogPrinter =new ServerLogPrinter(serverLogPath, true);
// serverLogPrinter.run();
WebLogPrinter webLogPrinter = new WebLogPrinter(webLogPath,false);
webLogPrinter.run();
FTPLogPrinter ftpLogPrinter = new FTPLogPrinter(ftpLogPath,false);
ftpLogPrinter.run();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}, 0, randomObjectUtil.getRandomNumber(5,1), TimeUnit.SECONDS);
}
}
log
最新推荐文章于 2023-12-16 19:28:29 发布