Kaynağa Gözat

日志上传打开删除文件的注释

chenweida 9 yıl önce
ebeveyn
işleme
21b2113564

+ 8 - 6
Hos-Resource-Mini-helper/src/main/java/com.yihu.ehr/thread/LogThread.java

@ -43,7 +43,7 @@ public class LogThread implements Runnable {
                            //发送日志文件
                            sendLogFile(file);
                            //删除日志文件
                            //deleteLogFile(file);
                            deleteLogFile(file);
                        }
                    }
                }
@ -96,7 +96,7 @@ public class LogThread implements Runnable {
            formParams.add(new BasicNameValuePair("access_token", token));
            formParams.add(new BasicNameValuePair("orgCode", orgCode));
            String booleanString = HttpsClientUtil.postFile(ThreadConfig.SERVICE_URL + ThreadConfig.LOG_THREAD_UPLOAD, file, formParams, ThreadConfig.SERVICE_USERNAME, ThreadConfig.SERVICE_PASSWORD);
            LogUtil.info("日志发送成功:" + booleanString);
            LogUtil.info("日志上传结果:" + booleanString);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
@ -105,7 +105,8 @@ public class LogThread implements Runnable {
        }
    }
    private void deleteLogFile(File file) {
    private void deleteLogFile(String filePathTemp) {
        File file=new File(filePathTemp);
        String filePath = file.getAbsolutePath();
        if (file.delete()) {
            LogUtil.info("日志删除成功");
@ -117,10 +118,11 @@ public class LogThread implements Runnable {
    public String getLogFile() {
        String home = System.getProperty("catalina.home").replace('\\', '/');
        String srcPath = home.substring(0, home.lastIndexOf('/') + 1) +  "log4j";
        String srcPath = home.substring(0, home.lastIndexOf('/') + 1) + "log4j";
        LogUtil.info("压缩日志,日志目录:" + srcPath);
        String filePath = srcPath + File.separator + logFileName;
        ZipUtil.zip(srcPath, filePath);
        LogUtil.info("日志文件路径:" + filePath);
        LogUtil.info("上传的日志文件路径:" + filePath);
        File file = new File(filePath);
        if (file.exists()) {
            LogUtil.info("-----------得到日志成功------------");
@ -133,7 +135,7 @@ public class LogThread implements Runnable {
    private void sleep() throws Exception {
        LogUtil.info("日志线程开始睡眠,睡眠时间(分钟):" + ThreadConfig.LOG_THREAD_SLEEP_TIME);
        Thread.sleep(sleepTime * ThreadConfig.SQL_THREAD_SLEEP_TIME);
        Thread.sleep(sleepTime * ThreadConfig.LOG_THREAD_SLEEP_TIME);
    }
    public static void main(String[] args) {

+ 2 - 2
Hos-Resource-Mini-helper/src/main/resources/config/threadConfig.properties

@ -1,9 +1,9 @@
soft.versionCode=1
## service address
service.url=https://172.19.103.73:443:443/api/v1.0/
service.url=https://172.19.103.73:443/api/v1.0/
service.clientId = kHAbVppx44
service.clientKey = Bd2h8rdYhep6NKOO
logThread.sleepTime=30
logThread.sleepTime=1
sqlThread.sleepTime=30