Commit c548c0a6 authored by 张俊's avatar 张俊

日志文件输出优化

parent 99c177d0
...@@ -2,7 +2,6 @@ package net.cdkj.gjj.adapter; ...@@ -2,7 +2,6 @@ package net.cdkj.gjj.adapter;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@SpringBootApplication @SpringBootApplication
......
...@@ -2,13 +2,8 @@ package net.cdkj.gjj.adapter.config; ...@@ -2,13 +2,8 @@ package net.cdkj.gjj.adapter.config;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.util.Properties;
/** /**
* druid 配置多数据源 * druid 配置多数据源
......
package net.cdkj.gjj.adapter.config; package net.cdkj.gjj.adapter.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -10,8 +9,6 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert ...@@ -10,8 +9,6 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
import org.springframework.web.client.DefaultResponseErrorHandler; import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.sql.DataSource;
/** /**
* 把RestTemplate注入Spring IOC容器 * 把RestTemplate注入Spring IOC容器
* *
...@@ -26,7 +23,7 @@ public class RestTemplateConfig { ...@@ -26,7 +23,7 @@ public class RestTemplateConfig {
RestTemplate restTemplate = restTemplateBuilder.build(); RestTemplate restTemplate = restTemplateBuilder.build();
// 设置HTTP request (请求)和response (响应)的转换器 // 设置HTTP request (请求)和response (响应)的转换器
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter()); restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
//错误响应处理 // 错误响应处理
restTemplate.setErrorHandler(new DefaultResponseErrorHandler() { restTemplate.setErrorHandler(new DefaultResponseErrorHandler() {
@Override @Override
protected boolean hasError(HttpStatus statusCode) { protected boolean hasError(HttpStatus statusCode) {
...@@ -41,5 +38,4 @@ public class RestTemplateConfig { ...@@ -41,5 +38,4 @@ public class RestTemplateConfig {
} }
} }
\ No newline at end of file
...@@ -4,14 +4,11 @@ package net.cdkj.gjj.adapter.controller; ...@@ -4,14 +4,11 @@ package net.cdkj.gjj.adapter.controller;
import net.cdkj.gjj.adapter.utils.InternalUtils; import net.cdkj.gjj.adapter.utils.InternalUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
/** /**
...@@ -42,7 +39,7 @@ public class AlarmTask { ...@@ -42,7 +39,7 @@ public class AlarmTask {
try { try {
providentFundServicesController.gjjxtfwjk(); providentFundServicesController.gjjxtfwjk();
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.error("{}", e);
} }
} }
......
...@@ -4,7 +4,10 @@ package net.cdkj.gjj.adapter.controller; ...@@ -4,7 +4,10 @@ package net.cdkj.gjj.adapter.controller;
import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import net.cdkj.gjj.adapter.domain.*; import net.cdkj.gjj.adapter.domain.AjaxResult;
import net.cdkj.gjj.adapter.domain.BusinessProcessing;
import net.cdkj.gjj.adapter.domain.Json;
import net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation;
import net.cdkj.gjj.adapter.utils.InternalUtils; import net.cdkj.gjj.adapter.utils.InternalUtils;
import oracle.jdbc.OracleTypes; import oracle.jdbc.OracleTypes;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -35,29 +38,51 @@ import java.util.List; ...@@ -35,29 +38,51 @@ import java.util.List;
@RequestMapping(value = "/InternalLogic") @RequestMapping(value = "/InternalLogic")
public class DeptInfoUpdateController { public class DeptInfoUpdateController {
private static final Logger log = LoggerFactory.getLogger(DeptInfoUpdateController.class);
@Resource @Resource
private RestTemplate restTemplate; private RestTemplate restTemplate;
@Resource @Resource
private DruidDataSource druidDataSource; private DruidDataSource druidDataSource;
@Value("${dwxxbgPullUrl}") @Value("${dwxxbgPullUrl}")
private String dwxxbgPullUrl; private String dwxxbgPullUrl;
@Value("${dwxxbgPushUrl}") @Value("${dwxxbgPushUrl}")
private String dwxxbgPushUrl; private String dwxxbgPushUrl;
@Value("${timetype}") @Value("${timetype}")
private String timetype; private String timetype;
@Value("${startTime}") @Value("${startTime}")
private String startTime; private String startTime;
@Value("${endTime}") @Value("${endTime}")
private String endTime; private String endTime;
private static final Logger log = LoggerFactory.getLogger(DeptInfoUpdateController.class); /**
* 模拟数据
*
* @return
*/
private static String mockDwxxbgHttp() {
List<UnitAccountOpeningInformation> informationList = new ArrayList<>();
UnitAccountOpeningInformation information = new UnitAccountOpeningInformation();
information.setBusId("2");
information.setUscc("91421122MAC7ANQB8C");
information.setEntName("红安县永利土石方工程有限公司");
information.setDom("湖北省黄冈市红安县高桥镇长扬路东端北侧119号");
information.setLerep("吴永利");
information.setCerType("10");
information.setCerNo("422123197810295851");
information.setOperatorName("吴永利");
information.setOperatorCerNo("422123197810295851");
information.setOperatorPhone("13872001037");
information.setOplocdistrict("421122");
information.setUnitNature("A313");
information.setEconomicType("1");
information.setIndustryphy("E");
information.setUnitPayDay("1");
informationList.add(information);
Json json = new Json();
json.setData(informationList);
String dwxxbgHttp = JSONObject.toJSONString(json);
return dwxxbgHttp;
}
/** /**
* 公积金系统服务接口内置机调前置机中间接口 * 公积金系统服务接口内置机调前置机中间接口
...@@ -84,7 +109,6 @@ public class DeptInfoUpdateController { ...@@ -84,7 +109,6 @@ public class DeptInfoUpdateController {
return forObject; return forObject;
} }
/** /**
* (第一个定时的) * (第一个定时的)
* 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口, * 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,
...@@ -202,37 +226,6 @@ public class DeptInfoUpdateController { ...@@ -202,37 +226,6 @@ public class DeptInfoUpdateController {
return AjaxResult.success("请求成功", null); return AjaxResult.success("请求成功", null);
} }
/**
* 模拟数据
*
* @return
*/
private static String mockDwxxbgHttp() {
List<UnitAccountOpeningInformation> informationList = new ArrayList<>();
UnitAccountOpeningInformation information = new UnitAccountOpeningInformation();
information.setBusId("2");
information.setUscc("91421122MAC7ANQB8C");
information.setEntName("红安县永利土石方工程有限公司");
information.setDom("湖北省黄冈市红安县高桥镇长扬路东端北侧119号");
information.setLerep("吴永利");
information.setCerType("10");
information.setCerNo("422123197810295851");
information.setOperatorName("吴永利");
information.setOperatorCerNo("422123197810295851");
information.setOperatorPhone("13872001037");
information.setOplocdistrict("421122");
information.setUnitNature("A313");
information.setEconomicType("1");
information.setIndustryphy("E");
information.setUnitPayDay("1");
informationList.add(information);
Json json = new Json();
json.setData(informationList);
String dwxxbgHttp = JSONObject.toJSONString(json);
return dwxxbgHttp;
}
/** /**
* 住建部门返回公积金办理进度数据接口方法 * 住建部门返回公积金办理进度数据接口方法
* (第二个定时) * (第二个定时)
......
...@@ -38,28 +38,41 @@ import java.util.List; ...@@ -38,28 +38,41 @@ import java.util.List;
@RequestMapping(value = "/InternalLogic") @RequestMapping(value = "/InternalLogic")
public class DeptLogoutController { public class DeptLogoutController {
private static final Logger log = LoggerFactory.getLogger(DeptLogoutController.class);
@Resource @Resource
private RestTemplate restTemplate; private RestTemplate restTemplate;
@Resource @Resource
private DruidDataSource druidDataSource; private DruidDataSource druidDataSource;
@Value("${dwxhPullUrl}") @Value("${dwxhPullUrl}")
private String dwxhPullUrl; private String dwxhPullUrl;
@Value("${dwxhPushUrl}") @Value("${dwxhPushUrl}")
private String dwxhPushUrl; private String dwxhPushUrl;
@Value("${timetype}") @Value("${timetype}")
private String timetype; private String timetype;
@Value("${startTime}") @Value("${startTime}")
private String startTime; private String startTime;
@Value("${endTime}") @Value("${endTime}")
private String endTime; private String endTime;
private static final Logger log = LoggerFactory.getLogger(DeptLogoutController.class); /**
* 模拟数据
*
* @return
*/
private static String mockDwxhHttp() {
List<UnitAccountOpeningInformation> informationList = new ArrayList<>();
UnitAccountOpeningInformation information = new UnitAccountOpeningInformation();
information.setBusId("2");
information.setUscc("91421122MAC7ANQB8C");
information.setEntName("红安县永利土石方工程有限公司");
information.setDom("湖北省黄冈市红安县高桥镇长扬路东端北侧119号");
information.setOplocdistrict("421122");
informationList.add(information);
Json json = new Json();
json.setData(informationList);
String dwxhHttp = JSONObject.toJSONString(json);
return dwxhHttp;
}
/** /**
* 公积金系统服务接口内置机调前置机中间接口 * 公积金系统服务接口内置机调前置机中间接口
...@@ -86,7 +99,6 @@ public class DeptLogoutController { ...@@ -86,7 +99,6 @@ public class DeptLogoutController {
return forObject; return forObject;
} }
/** /**
* (第一个定时的) * (第一个定时的)
* 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口, * 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,
...@@ -173,27 +185,6 @@ public class DeptLogoutController { ...@@ -173,27 +185,6 @@ public class DeptLogoutController {
return AjaxResult.success("请求成功", null); return AjaxResult.success("请求成功", null);
} }
/**
* 模拟数据
*
* @return
*/
private static String mockDwxhHttp() {
List<UnitAccountOpeningInformation> informationList = new ArrayList<>();
UnitAccountOpeningInformation information = new UnitAccountOpeningInformation();
information.setBusId("2");
information.setUscc("91421122MAC7ANQB8C");
information.setEntName("红安县永利土石方工程有限公司");
information.setDom("湖北省黄冈市红安县高桥镇长扬路东端北侧119号");
information.setOplocdistrict("421122");
informationList.add(information);
Json json = new Json();
json.setData(informationList);
String dwxhHttp = JSONObject.toJSONString(json);
return dwxhHttp;
}
/** /**
* 住建部门返回公积金办理进度数据接口方法 * 住建部门返回公积金办理进度数据接口方法
* (第二个定时) * (第二个定时)
......
package net.cdkj.gjj.adapter.controller; package net.cdkj.gjj.adapter.controller;
import net.cdkj.gjj.adapter.config.JasyptConfig;
import org.jasypt.encryption.StringEncryptor; import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
......
...@@ -4,7 +4,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -4,7 +4,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping(value="demo") @RequestMapping(value = "demo")
public class TestController { public class TestController {
@RequestMapping("test") @RequestMapping("test")
......
...@@ -10,27 +10,23 @@ import java.util.HashMap; ...@@ -10,27 +10,23 @@ import java.util.HashMap;
* @author ruoyi * @author ruoyi
*/ */
public class AjaxResult extends HashMap<String, Object> { public class AjaxResult extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
/** /**
* 状态码 * 状态码
*/ */
public static final String CODE_TAG = "code"; public static final String CODE_TAG = "code";
/** /**
* 返回内容 * 返回内容
*/ */
public static final String MSG_TAG = "msg"; public static final String MSG_TAG = "msg";
/** /**
* 数据对象 * 数据对象
*/ */
public static final String DATA_TAG = "data"; public static final String DATA_TAG = "data";
/** /**
* 总数 * 总数
*/ */
public static final String TOTAL_TAG = "total"; public static final String TOTAL_TAG = "total";
private static final long serialVersionUID = 1L;
/** /**
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
...@@ -85,7 +81,6 @@ public class AjaxResult extends HashMap<String, Object> { ...@@ -85,7 +81,6 @@ public class AjaxResult extends HashMap<String, Object> {
} }
/** /**
* 返回成功消息 * 返回成功消息
* *
......
...@@ -2,8 +2,6 @@ package net.cdkj.gjj.adapter.domain; ...@@ -2,8 +2,6 @@ package net.cdkj.gjj.adapter.domain;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Date;
/** /**
* 业务办理进度数据对象 * 业务办理进度数据对象
*/ */
......
...@@ -7,11 +7,11 @@ import java.util.List; ...@@ -7,11 +7,11 @@ import java.util.List;
*/ */
public class Json { public class Json {
private Integer code; private Integer code;
private String message; private String message;
private String fields; private String fields;
private List<UnitAccountOpeningInformation> data; private List<UnitAccountOpeningInformation> data;
......
package net.cdkj.gjj.adapter.domain; package net.cdkj.gjj.adapter.domain;
import net.cdkj.gjj.adapter.controller.DeptInfoUpdateController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
...@@ -8,43 +13,47 @@ import java.util.Properties; ...@@ -8,43 +13,47 @@ import java.util.Properties;
* 获取配置文件application.properties里的属性值所用到的工具类 * 获取配置文件application.properties里的属性值所用到的工具类
*/ */
public class PropertyqUtil { public class PropertyqUtil {
private static final Logger log = LoggerFactory.getLogger(DeptInfoUpdateController.class);
/** /**
* 读取 classpath 下 指定的properties配置文件,加载到Properties并返回Properties * 读取 classpath 下 指定的properties配置文件,加载到Properties并返回Properties
*
* @param name 配置文件名,如:mongo.properties * @param name 配置文件名,如:mongo.properties
* @return * @return
*/ */
public static Properties getConfig(String name){ public static Properties getConfig(String name) {
Properties props=null; Properties props = null;
try{ try {
props = new Properties(); props = new Properties();
InputStream in = PropertyqUtil.class.getClassLoader().getResourceAsStream(name); InputStream in = PropertyqUtil.class.getClassLoader().getResourceAsStream(name);
BufferedReader bf = new BufferedReader(new InputStreamReader(in)); BufferedReader bf = new BufferedReader(new InputStreamReader(in));
props.load(bf); props.load(bf);
in.close(); in.close();
}catch(Exception ex){ } catch (Exception e) {
ex.printStackTrace(); log.error("{}", e);
} }
return props; return props;
} }
public static String getPropValue(Properties prop,String key){ public static String getPropValue(Properties prop, String key) {
if(key == null || "".equals(key.trim())){ if (key == null || "".equals(key.trim())) {
return null; return null;
} }
String value = prop.getProperty(key); String value = prop.getProperty(key);
if(value == null){ if (value == null) {
return null; return null;
} }
value = value.trim(); value = value.trim();
//判断是否是环境变量配置属性,例如 server.env=${serverEnv:local} // 判断是否是环境变量配置属性,例如 server.env=${serverEnv:local}
if(value.startsWith("${") && value.endsWith("}") && value.contains(":")){ if (value.startsWith("${") && value.endsWith("}") && value.contains(":")) {
int indexOfColon = value.indexOf(":"); int indexOfColon = value.indexOf(":");
String envName = value.substring(2,indexOfColon); String envName = value.substring(2, indexOfColon);
//获取系统环境变量 envName 的内容,如果没有找到,则返回defaultValue // 获取系统环境变量 envName 的内容,如果没有找到,则返回defaultValue
String envValue = System.getenv(envName); String envValue = System.getenv(envName);
if(envValue == null){ if (envValue == null) {
//配置的默认值 // 配置的默认值
return value.substring(indexOfColon+1,value.length()-1); return value.substring(indexOfColon + 1, value.length() - 1);
} }
return envValue; return envValue;
} }
......
...@@ -10,53 +10,53 @@ import java.util.Date; ...@@ -10,53 +10,53 @@ import java.util.Date;
@JsonInclude(JsonInclude.Include.NON_NULL) @JsonInclude(JsonInclude.Include.NON_NULL)
public class UnitAccountOpeningInformation { public class UnitAccountOpeningInformation {
private String ywbh; private String ywbh;
private String busId; private String busId;
private String uscc; private String uscc;
private String entName; private String entName;
private String dom; private String dom;
private Date estDate; private Date estDate;
private String lerep; private String lerep;
private String cerType; private String cerType;
private String cerNo; private String cerNo;
private String operatorName; private String operatorName;
private String operatorCerNo; private String operatorCerNo;
private String operatorPhone; private String operatorPhone;
private String oplocdistrict; private String oplocdistrict;
private String unitNature; private String unitNature;
private String economicType; private String economicType;
private String industryphy; private String industryphy;
private String unitPayDay; private String unitPayDay;
private String unitDepPro; private String unitDepPro;
private String personalDepPro; private String personalDepPro;
private String zxdqbm; private String zxdqbm;
private String lcls; private String lcls;
private String dwzh; private String dwzh;
private String errcode; private String errcode;
private String errmsg; private String errmsg;
public String getBusId() { public String getBusId() {
...@@ -199,6 +199,10 @@ public class UnitAccountOpeningInformation { ...@@ -199,6 +199,10 @@ public class UnitAccountOpeningInformation {
return personalDepPro; return personalDepPro;
} }
public void setPersonalDepPro(String personalDepPro) {
this.personalDepPro = personalDepPro;
}
public String getYwbh() { public String getYwbh() {
return ywbh; return ywbh;
} }
...@@ -247,10 +251,6 @@ public class UnitAccountOpeningInformation { ...@@ -247,10 +251,6 @@ public class UnitAccountOpeningInformation {
this.errmsg = errmsg; this.errmsg = errmsg;
} }
public void setPersonalDepPro(String personalDepPro) {
this.personalDepPro = personalDepPro;
}
@Override @Override
public String toString() { public String toString() {
return "UnitAccountOpeningInformation{" + return "UnitAccountOpeningInformation{" +
......
package net.cdkj.gjj.adapter.utils; package net.cdkj.gjj.adapter.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
import java.util.zip.GZIPInputStream;
public class HttpUtil { public class HttpUtil {
private static final Logger logger = LoggerFactory.getLogger(InternalUtils.class);
/** /**
* 获取请求入参数据 * 获取请求入参数据
*/ */
...@@ -22,10 +26,10 @@ public class HttpUtil { ...@@ -22,10 +26,10 @@ public class HttpUtil {
json.append(line); json.append(line);
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println(e); logger.error("{}", e);
} }
String str = json.toString(); String str = json.toString();
System.out.println("要发送给第三方的公积金系统服务报文:" + str); logger.info("要发送给第三方的公积金系统服务报文:" + str);
return str; return str;
} }
...@@ -75,14 +79,13 @@ public class HttpUtil { ...@@ -75,14 +79,13 @@ public class HttpUtil {
sb.append(readLine); sb.append(readLine);
} }
responseReader.close(); responseReader.close();
System.out.println("前置机返回第三方解压之后数据:" + sb); logger.info("前置机返回第三方解压之后数据:" + sb);
return sb.toString(); return sb.toString();
} else { } else {
System.out.println("请求失败!!!"); logger.info("请求失败!!!");
} }
} catch ( } catch (IOException e) {
IOException e) { logger.error("{}", e);
e.printStackTrace();
} finally { } finally {
if (out != null) { if (out != null) {
try { try {
......
package net.cdkj.gjj.adapter.utils; package net.cdkj.gjj.adapter.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collection; import java.util.Collection;
...@@ -8,6 +11,7 @@ import java.util.Map; ...@@ -8,6 +11,7 @@ import java.util.Map;
public class InternalUtils { public class InternalUtils {
private static final Logger logger = LoggerFactory.getLogger(InternalUtils.class);
/** /**
* 判断一个实体对象是否为空 * 判断一个实体对象是否为空
...@@ -57,7 +61,7 @@ public class InternalUtils { ...@@ -57,7 +61,7 @@ public class InternalUtils {
curentDay.set(Calendar.SECOND, 0); curentDay.set(Calendar.SECOND, 0);
SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss"); SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
time = df2.format(curentDay.getTime().getTime()); time = df2.format(curentDay.getTime().getTime());
System.out.println(time); logger.error("type == 0 time:{}", time);
} else if (type == 24) { } else if (type == 24) {
// 获取当天24点零分零秒的时间戳,即第二天零点时间 // 获取当天24点零分零秒的时间戳,即第二天零点时间
Calendar curentDay = Calendar.getInstance(); Calendar curentDay = Calendar.getInstance();
...@@ -67,7 +71,7 @@ public class InternalUtils { ...@@ -67,7 +71,7 @@ public class InternalUtils {
curentDay.set(Calendar.SECOND, 0); curentDay.set(Calendar.SECOND, 0);
SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss"); SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
time = df2.format(curentDay.getTime().getTime()); time = df2.format(curentDay.getTime().getTime());
System.out.println(time); logger.error("type == 24 time:{}", time);
} }
return time; return time;
} }
......
...@@ -50,5 +50,5 @@ dwxhPushTaskDelay:60000 ...@@ -50,5 +50,5 @@ dwxhPushTaskDelay:60000
dwxhPullTaskDelay:60000 dwxhPullTaskDelay:60000
# 日志配置 # 日志配置
logging.config:classpath:logback-spring.xml logging.config:classpath:logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="C:/logs"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-debug.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-debug.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.cdkj" level="debug"/>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="console"/>
<appender-ref ref="file_debug"/>
<appender-ref ref="file_error"/>
</root>
</configuration>
...@@ -18,21 +18,13 @@ ...@@ -18,21 +18,13 @@
<!-- 循环政策:基于时间创建日志文件 --> <!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 --> <!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern> <fileNamePattern>${log.path}.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 --> <!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory> <maxHistory>30</maxHistory>
</rollingPolicy> </rollingPolicy>
<encoder> <encoder>
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
</encoder> </encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender> </appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender"> <appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
...@@ -40,9 +32,9 @@ ...@@ -40,9 +32,9 @@
<!-- 循环政策:基于时间创建日志文件 --> <!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 --> <!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern> <fileNamePattern>${log.path}-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 --> <!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory> <maxHistory>30</maxHistory>
</rollingPolicy> </rollingPolicy>
<encoder> <encoder>
<pattern>${log.pattern}</pattern> <pattern>${log.pattern}</pattern>
...@@ -57,38 +49,13 @@ ...@@ -57,38 +49,13 @@
</filter> </filter>
</appender> </appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<!-- 控制台输出 -->
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志--> <!--系统操作日志-->
<root level="info"> <root level="info">
<appender-ref ref="console"/>
<appender-ref ref="file_info"/> <appender-ref ref="file_info"/>
<appender-ref ref="file_error"/> <appender-ref ref="file_error"/>
</root> </root>
<!-- 系统模块日志级别控制 -->
<logger name="net.cdkj" level="debug"/>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration> </configuration>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment