由于log4j自带的文件分裂功能无法使用,故在代码内部实现当log文件大于一定数值时拷贝并清空
String filename = System.getProperty("catalina.base") +"/logs/tomcat8-stdout.log";
LOG.info("filename="+filename);
File logfile = new File(filename);
long lenth = logfile.length();
LOG.info("lenth="+lenth);
long MaxLengh = 20*1024*1024;
if(logfile.length()>MaxLengh) { //判断log文件是否大于20M
//原始文档路径
String old = System.getProperty("catalina.base") +"/logs/tomcat8-stdout.log";
//新文档路径
String newPath = System.getProperty("catalina.base") +"/logs/tomcat8-stdout_copy.log";
//将原始文档通过输入流读入内存
FileInputStream fis = new FileInputStream(new File(old));
BufferedInputStream bis = new BufferedInputStream(fis);
InputStreamReader isr = new InputStreamReader(bis);
BufferedReader br = new