Commit c548c0a6 authored by 张俊's avatar 张俊

日志文件输出优化

parent 99c177d0
......@@ -2,7 +2,6 @@ package net.cdkj.gjj.adapter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@SpringBootApplication
......
......@@ -2,13 +2,8 @@ package net.cdkj.gjj.adapter.config;
import com.alibaba.druid.pool.DruidDataSource;
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.Configuration;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.util.Properties;
/**
* druid 配置多数据源
......
package net.cdkj.gjj.adapter.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
......@@ -10,8 +9,6 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.RestTemplate;
import javax.sql.DataSource;
/**
* 把RestTemplate注入Spring IOC容器
*
......@@ -26,7 +23,7 @@ public class RestTemplateConfig {
RestTemplate restTemplate = restTemplateBuilder.build();
// 设置HTTP request (请求)和response (响应)的转换器
restTemplate.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
//错误响应处理
// 错误响应处理
restTemplate.setErrorHandler(new DefaultResponseErrorHandler() {
@Override
protected boolean hasError(HttpStatus statusCode) {
......@@ -41,5 +38,4 @@ public class RestTemplateConfig {
}
}
\ No newline at end of file
......@@ -4,14 +4,11 @@ package net.cdkj.gjj.adapter.controller;
import net.cdkj.gjj.adapter.utils.InternalUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
......@@ -42,7 +39,7 @@ public class AlarmTask {
try {
providentFundServicesController.gjjxtfwjk();
} catch (Exception e) {
e.printStackTrace();
log.error("{}", e);
}
}
......
......@@ -4,7 +4,10 @@ package net.cdkj.gjj.adapter.controller;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.fastjson.JSON;
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 oracle.jdbc.OracleTypes;
import org.slf4j.Logger;
......@@ -35,29 +38,51 @@ import java.util.List;
@RequestMapping(value = "/InternalLogic")
public class DeptInfoUpdateController {
private static final Logger log = LoggerFactory.getLogger(DeptInfoUpdateController.class);
@Resource
private RestTemplate restTemplate;
@Resource
private DruidDataSource druidDataSource;
@Value("${dwxxbgPullUrl}")
private String dwxxbgPullUrl;
@Value("${dwxxbgPushUrl}")
private String dwxxbgPushUrl;
@Value("${timetype}")
private String timetype;
@Value("${startTime}")
private String startTime;
@Value("${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 {
return forObject;
}
/**
* (第一个定时的)
* 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,
......@@ -202,37 +226,6 @@ public class DeptInfoUpdateController {
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;
@RequestMapping(value = "/InternalLogic")
public class DeptLogoutController {
private static final Logger log = LoggerFactory.getLogger(DeptLogoutController.class);
@Resource
private RestTemplate restTemplate;
@Resource
private DruidDataSource druidDataSource;
@Value("${dwxhPullUrl}")
private String dwxhPullUrl;
@Value("${dwxhPushUrl}")
private String dwxhPushUrl;
@Value("${timetype}")
private String timetype;
@Value("${startTime}")
private String startTime;
@Value("${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 {
return forObject;
}
/**
* (第一个定时的)
* 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,
......@@ -173,27 +185,6 @@ public class DeptLogoutController {
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;
import net.cdkj.gjj.adapter.config.JasyptConfig;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......
......@@ -9,6 +9,8 @@ import net.cdkj.gjj.adapter.domain.UnitAccountOpeningInformation;
import net.cdkj.gjj.adapter.utils.HttpUtil;
import net.cdkj.gjj.adapter.utils.InternalUtils;
import oracle.jdbc.OracleTypes;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -30,6 +32,10 @@ import java.util.*;
public class ProvidentFundServicesController {
// sl4j
private static final Logger logger = LoggerFactory.getLogger(ProvidentFundServicesController.class);
@Resource
private DruidDataSource dataSource;
......@@ -49,6 +55,48 @@ public class ProvidentFundServicesController {
@Value("${endTime}")
private String endTime;
/**
* 获取当天零点零分零秒的时间戳和当天24点的时间戳
*
* @return
*/
@ResponseBody
@PostMapping("currentime")
public static String currenttime(int type) {
return InternalUtils.currentTime(type);
}
/**
* 判断一个实体对象是否为空
*
* @param obj
* @return
*/
public static boolean isNullOrEmpty(Object obj) {
if (obj == null)
return true;
if (obj instanceof CharSequence)
return ((CharSequence) obj).length() == 0;
if (obj instanceof Collection)
return ((Collection) obj).isEmpty();
if (obj instanceof Map)
return ((Map) obj).isEmpty();
if (obj instanceof Object[]) {
Object[] object = (Object[]) obj;
if (object.length == 0) {
return true;
}
boolean empty = true;
for (int i = 0; i < object.length; i++) {
if (!isNullOrEmpty(object[i])) {
empty = false;
break;
}
}
return empty;
}
return false;
}
/**
* 公积金系统服务接口内置机调前置机中间接口
......@@ -74,17 +122,6 @@ public class ProvidentFundServicesController {
return HttpUtil.sendPost(dwkhPullUrl, str);
}
/**
* 获取当天零点零分零秒的时间戳和当天24点的时间戳
*
* @return
*/
@ResponseBody
@PostMapping("currentime")
public static String currenttime(int type) {
return InternalUtils.currentTime(type);
}
/**
* (第一个定时的)
* 调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,
......@@ -97,7 +134,7 @@ public class ProvidentFundServicesController {
public void gjjxtfwjk() throws Exception {
// 1.调用公积金系统服务接口方法,请求前置机,让前置机请求市监接口,拿到市监返回的开户信息json数据,经过前置机zip解压返回给本内置机处理
String jsoninfom = ProvidentFundServices();
System.out.println("拿到第一个接口返回的第三方数据,准备调第一个存储过程" + jsoninfom);
logger.info("拿到第一个接口返回的第三方数据,准备调第一个存储过程" + jsoninfom);
Json jsonentity = JSONObject.parseObject(jsoninfom, Json.class);
List<UnitAccountOpeningInformation> bills = new ArrayList<>();
if (!isNullOrEmpty(jsonentity)) {
......@@ -113,7 +150,7 @@ public class ProvidentFundServicesController {
if (!bills.isEmpty()) {
for (UnitAccountOpeningInformation uniInfom : bills) {
if (!"".equals(uniInfom.getOplocdistrict()) && uniInfom.getOplocdistrict() != null) {
System.out.println("oplocdistrict" + "在规定的值里面,调imp过程");
logger.info("oplocdistrict" + "在规定的值里面,调imp过程");
if (!"".equals(uniInfom.getBusId()) && uniInfom.getBusId() != null) {
pstm.setString(1, uniInfom.getBusId());
} else {
......@@ -226,17 +263,17 @@ public class ProvidentFundServicesController {
// 执行数据库查询操作
pstm.execute();
// 输出结果[第二个参数]
System.out.println(pstm.getString(19));
System.out.println(pstm.getString(20));
logger.info(pstm.getString(19));
logger.info(pstm.getString(20));
if ("".equals(pstm.getString(19)) || pstm.getString(19) == null) {
break;
} else {
try {
// 避免批量插入高并发,此处设置每次停顿5秒
Thread.currentThread().sleep(2000);
System.out.println("间隔2秒传一条数据调一次存储过程");
logger.info("间隔2秒传一条数据调一次存储过程");
} catch (InterruptedException e) {
e.printStackTrace();
logger.error("{}", e);
}
}
......@@ -244,7 +281,7 @@ public class ProvidentFundServicesController {
}
pstm2.execute();
} else {
System.out.println("第三方返回的报文中data数据为空!");
logger.info("第三方返回的报文中data数据为空!");
}
// 释放资源
pstm.close();
......@@ -252,38 +289,6 @@ public class ProvidentFundServicesController {
connection.close();
}
/**
* 判断一个实体对象是否为空
*
* @param obj
* @return
*/
public static boolean isNullOrEmpty(Object obj) {
if (obj == null)
return true;
if (obj instanceof CharSequence)
return ((CharSequence) obj).length() == 0;
if (obj instanceof Collection)
return ((Collection) obj).isEmpty();
if (obj instanceof Map)
return ((Map) obj).isEmpty();
if (obj instanceof Object[]) {
Object[] object = (Object[]) obj;
if (object.length == 0) {
return true;
}
boolean empty = true;
for (int i = 0; i < object.length; i++) {
if (!isNullOrEmpty(object[i])) {
empty = false;
break;
}
}
return empty;
}
return false;
}
/**
* 住建部门返回公积金办理进度数据接口方法
* (第二个定时)
......@@ -294,15 +299,15 @@ public class ProvidentFundServicesController {
@ResponseBody
@PostMapping("BusinessProcessing")
public String BusinessProcessing() {
System.out.println("调第二个接口了");
logger.info("调第二个接口了");
// 调oracle存储过程拿到进度推进的数据集合
List<BusinessProcessing> list = null;
try {
list = zjbmfhywtosj();
} catch (Exception e) {
e.printStackTrace();
logger.error("{}", e);
}
System.out.println("调第二个接口了存储过程返回的list" + list);
logger.info("调第二个接口了存储过程返回的list" + list);
JSONObject jsonObject = new JSONObject();
jsonObject.put("state", "1");
if (!list.isEmpty()) {
......@@ -326,7 +331,7 @@ public class ProvidentFundServicesController {
if (!list.isEmpty()) {
uscc = list.get(0).getUscc();
}
System.out.println(uscc);
logger.info(uscc);
JSONObject jsonObj = JSONObject.parseObject(result);
String success = jsonObj.getString("success");
Integer value = 0;
......@@ -338,9 +343,9 @@ public class ProvidentFundServicesController {
try {
zjbmfhywtosjHX(uscc, value);
} catch (Exception e) {
e.printStackTrace();
logger.error("{}", e);
}
System.out.println(value);
logger.info("success:{}", value);
}
return result;
}
......@@ -368,48 +373,39 @@ public class ProvidentFundServicesController {
List<BusinessProcessing> list = new ArrayList<>();
while (rs.next()) {
BusinessProcessing b = new BusinessProcessing();
// System.out.println(rs.getString(1));//获取具体的值
if (!"".equals(rs.getString(1)) && rs.getString(1) != null) {
b.setBusiLink(rs.getString(1));
}
// System.out.println(rs.getString(2));//获取具体的值
if (!"".equals(rs.getString(2)) && rs.getString(2) != null) {
b.setBusiType(rs.getString(2));
}
// System.out.println(rs.getString(3));//获取具体的值
if (!"".equals(rs.getString(3)) && rs.getString(3) != null) {
b.setOpeartor(rs.getString(3));
}
// System.out.println(rs.getString(4));//获取具体的值
if (!"".equals(rs.getString(4)) && rs.getString(4) != null) {
b.setTel(rs.getString(4));
}
// System.out.println(rs.getString(5));//获取具体的值
if (!"".equals(rs.getString(5)) && rs.getString(5) != null) {
b.setOpinion(rs.getString(5));
}
// System.out.println(rs.getString(6));//获取具体的值
if (!"".equals(rs.getString(6)) && rs.getString(6) != null) {
b.setResult(rs.getString(6));
}
if (!"".equals(rs.getString(7)) && rs.getString(7) != null) {
b.setTime(rs.getString(7).substring(0, 19));
}
// System.out.println(rs.getString(8));//获取具体的值
if (!"".equals(rs.getString(8)) && rs.getString(8) != null) {
b.setUscc(rs.getString(8));
}
// System.out.println(rs.getString(9));//获取具体的值
if (!"".equals(rs.getString(9)) && rs.getString(9) != null) {
b.setEntName(rs.getString(9));
}
// System.out.println(rs.getString(10));//获取具体的值
if (!"".equals(rs.getString(10)) && rs.getString(10) != null) {
b.setBusId(rs.getString(10));
}
list.add(b);
}
System.out.println(list);
logger.info("获取结果:{}", list);
// 释放资源
pstm.close();
connection.close();
......
......@@ -4,7 +4,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value="demo")
@RequestMapping(value = "demo")
public class TestController {
@RequestMapping("test")
......
......@@ -10,27 +10,23 @@ import java.util.HashMap;
* @author ruoyi
*/
public class AjaxResult extends HashMap<String, Object> {
private static final long serialVersionUID = 1L;
/**
* 状态码
*/
public static final String CODE_TAG = "code";
/**
* 返回内容
*/
public static final String MSG_TAG = "msg";
/**
* 数据对象
*/
public static final String DATA_TAG = "data";
/**
* 总数
*/
public static final String TOTAL_TAG = "total";
private static final long serialVersionUID = 1L;
/**
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
......@@ -85,7 +81,6 @@ public class AjaxResult extends HashMap<String, Object> {
}
/**
* 返回成功消息
*
......
......@@ -2,8 +2,6 @@ package net.cdkj.gjj.adapter.domain;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.Date;
/**
* 业务办理进度数据对象
*/
......
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.InputStream;
import java.io.InputStreamReader;
......@@ -8,43 +13,47 @@ import java.util.Properties;
* 获取配置文件application.properties里的属性值所用到的工具类
*/
public class PropertyqUtil {
private static final Logger log = LoggerFactory.getLogger(DeptInfoUpdateController.class);
/**
* 读取 classpath 下 指定的properties配置文件,加载到Properties并返回Properties
*
* @param name 配置文件名,如:mongo.properties
* @return
*/
public static Properties getConfig(String name){
Properties props=null;
try{
public static Properties getConfig(String name) {
Properties props = null;
try {
props = new Properties();
InputStream in = PropertyqUtil.class.getClassLoader().getResourceAsStream(name);
BufferedReader bf = new BufferedReader(new InputStreamReader(in));
props.load(bf);
in.close();
}catch(Exception ex){
ex.printStackTrace();
} catch (Exception e) {
log.error("{}", e);
}
return props;
}
public static String getPropValue(Properties prop,String key){
if(key == null || "".equals(key.trim())){
public static String getPropValue(Properties prop, String key) {
if (key == null || "".equals(key.trim())) {
return null;
}
String value = prop.getProperty(key);
if(value == null){
if (value == null) {
return null;
}
value = value.trim();
//判断是否是环境变量配置属性,例如 server.env=${serverEnv:local}
if(value.startsWith("${") && value.endsWith("}") && value.contains(":")){
// 判断是否是环境变量配置属性,例如 server.env=${serverEnv:local}
if (value.startsWith("${") && value.endsWith("}") && value.contains(":")) {
int indexOfColon = value.indexOf(":");
String envName = value.substring(2,indexOfColon);
//获取系统环境变量 envName 的内容,如果没有找到,则返回defaultValue
String envName = value.substring(2, indexOfColon);
// 获取系统环境变量 envName 的内容,如果没有找到,则返回defaultValue
String envValue = System.getenv(envName);
if(envValue == null){
//配置的默认值
return value.substring(indexOfColon+1,value.length()-1);
if (envValue == null) {
// 配置的默认值
return value.substring(indexOfColon + 1, value.length() - 1);
}
return envValue;
}
......
......@@ -199,6 +199,10 @@ public class UnitAccountOpeningInformation {
return personalDepPro;
}
public void setPersonalDepPro(String personalDepPro) {
this.personalDepPro = personalDepPro;
}
public String getYwbh() {
return ywbh;
}
......@@ -247,10 +251,6 @@ public class UnitAccountOpeningInformation {
this.errmsg = errmsg;
}
public void setPersonalDepPro(String personalDepPro) {
this.personalDepPro = personalDepPro;
}
@Override
public String toString() {
return "UnitAccountOpeningInformation{" +
......
package net.cdkj.gjj.adapter.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.zip.GZIPInputStream;
public class HttpUtil {
private static final Logger logger = LoggerFactory.getLogger(InternalUtils.class);
/**
* 获取请求入参数据
*/
......@@ -22,10 +26,10 @@ public class HttpUtil {
json.append(line);
}
} catch (Exception e) {
System.out.println(e);
logger.error("{}", e);
}
String str = json.toString();
System.out.println("要发送给第三方的公积金系统服务报文:" + str);
logger.info("要发送给第三方的公积金系统服务报文:" + str);
return str;
}
......@@ -75,14 +79,13 @@ public class HttpUtil {
sb.append(readLine);
}
responseReader.close();
System.out.println("前置机返回第三方解压之后数据:" + sb);
logger.info("前置机返回第三方解压之后数据:" + sb);
return sb.toString();
} else {
System.out.println("请求失败!!!");
logger.info("请求失败!!!");
}
} catch (
IOException e) {
e.printStackTrace();
} catch (IOException e) {
logger.error("{}", e);
} finally {
if (out != null) {
try {
......
package net.cdkj.gjj.adapter.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collection;
......@@ -8,6 +11,7 @@ import java.util.Map;
public class InternalUtils {
private static final Logger logger = LoggerFactory.getLogger(InternalUtils.class);
/**
* 判断一个实体对象是否为空
......@@ -57,7 +61,7 @@ public class InternalUtils {
curentDay.set(Calendar.SECOND, 0);
SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
time = df2.format(curentDay.getTime().getTime());
System.out.println(time);
logger.error("type == 0 time:{}", time);
} else if (type == 24) {
// 获取当天24点零分零秒的时间戳,即第二天零点时间
Calendar curentDay = Calendar.getInstance();
......@@ -67,7 +71,7 @@ public class InternalUtils {
curentDay.set(Calendar.SECOND, 0);
SimpleDateFormat df2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
time = df2.format(curentDay.getTime().getTime());
System.out.println(time);
logger.error("type == 24 time:{}", time);
}
return time;
}
......
......@@ -50,5 +50,5 @@ dwxhPushTaskDelay: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 @@
<!-- 循环政策:基于时间创建日志文件 -->
<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天 -->
<maxHistory>60</maxHistory>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
......@@ -40,9 +32,9 @@
<!-- 循环政策:基于时间创建日志文件 -->
<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天 -->
<maxHistory>60</maxHistory>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
......@@ -57,38 +49,13 @@
</filter>
</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">
<appender-ref ref="console"/>
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
<!-- 系统模块日志级别控制 -->
<logger name="net.cdkj" level="debug"/>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</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