修改项目中的日志框架为log4j2异步形式输出,解决mybatis日志在控制台直接打印等的问题
This commit is contained in:
60
pom.xml
60
pom.xml
@@ -394,24 +394,44 @@
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.slf4j</groupId> -->
|
||||
<!-- <artifactId>slf4j-api</artifactId> -->
|
||||
<!-- <version>${slf4j.version}</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>org.slf4j</groupId> -->
|
||||
<!-- <artifactId>slf4j-log4j12</artifactId> -->
|
||||
<!-- <version>${slf4j.version}</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.14</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-jcl</artifactId>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-slf4j-impl</artifactId>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>2.11.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>log4j</groupId> -->
|
||||
<!-- <artifactId>log4j</artifactId> -->
|
||||
<!-- <version>1.2.14</version> -->
|
||||
<!-- </dependency> -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis</groupId>
|
||||
@@ -537,6 +557,14 @@
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jsp-api-2.1</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -3,15 +3,15 @@ package com.nis.interceptor;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.nis.datasource.CustomerContextHolder;
|
||||
|
||||
public class DataSourceAInterceptor implements HandlerInterceptor {
|
||||
Logger logger = Logger.getLogger(DataSourceAInterceptor.class);
|
||||
|
||||
private static final Logger logger =LoggerFactory.getLogger(DataSourceAInterceptor.class);
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
|
||||
throws Exception {
|
||||
|
||||
@@ -3,14 +3,16 @@ package com.nis.interceptor;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.nis.datasource.CustomerContextHolder;
|
||||
|
||||
public class DataSourceBInterceptor implements HandlerInterceptor {
|
||||
Logger logger = Logger.getLogger(DataSourceBInterceptor.class);
|
||||
private static final Logger logger =LoggerFactory.getLogger(DataSourceBInterceptor.class);
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request,
|
||||
HttpServletResponse response, Object handler) throws Exception {
|
||||
|
||||
@@ -12,7 +12,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
|
||||
@@ -23,7 +24,7 @@ import com.zdjizhi.utils.StringUtil;
|
||||
* @version 2014-4-15
|
||||
*/
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
|
||||
public static final Logger logger = Logger.getLogger(DateUtils.class);
|
||||
public static final Logger logger =LoggerFactory.getLogger(DateUtils.class);
|
||||
private static String[] parsePatterns = { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM", "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss",
|
||||
"yyyy.MM.dd HH:mm", "yyyy.MM" };
|
||||
|
||||
@@ -18,18 +18,19 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
import org.apache.ibatis.mapping.ResultMap;
|
||||
import org.apache.ibatis.mapping.ResultMapping;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.util.redis.SaveRedisListThread;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
|
||||
public class HiveJDBC {
|
||||
private final static Logger logger = Logger.getLogger(HiveJDBC.class);
|
||||
private static final Logger logger =LoggerFactory.getLogger(HiveJDBC.class);
|
||||
static Connection conn = null;
|
||||
static ResultSet rs = null;
|
||||
static Statement st = null;
|
||||
|
||||
@@ -221,6 +221,7 @@ public class JedisUtils {
|
||||
*/
|
||||
public static Jedis getResource(int redisDb) throws JedisException {
|
||||
JedisSentinelPool jedisSentinelPool = SpringContextHolder.getBean(JedisSentinelPool.class);
|
||||
// JedisPool jedisSentinelPool = SpringContextHolder.getBean(JedisPool.class);
|
||||
|
||||
if (jedisSentinelPool == null) {
|
||||
throw new ServiceRuntimeException("redis连接池为空,请联系管理员检查程序",
|
||||
|
||||
@@ -21,23 +21,25 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.ibatis.mapping.ResultMap;
|
||||
import org.apache.ibatis.mapping.ResultMapping;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nis.domain.LogEntity;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.HiveJDBC;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.StringUtils;
|
||||
import com.nis.util.httpclient.HttpClientUtil;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* @ClassName: ElasticsearchSqlUtil.java
|
||||
@@ -48,7 +50,9 @@ import com.nis.web.service.SpringContextHolder;
|
||||
*/
|
||||
@SuppressWarnings({"unchecked","rawtypes"})
|
||||
public class ElasticsearchSqlDao {
|
||||
private static final Logger logger=Logger.getLogger(ElasticsearchSqlDao.class);
|
||||
|
||||
private static final Logger logger =LoggerFactory.getLogger(ElasticsearchSqlDao.class);
|
||||
|
||||
private static final SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
private static final Map<Class,Map<String,String>> fieldsMapMap=new HashMap<>();
|
||||
public void init(Class clazz){
|
||||
|
||||
@@ -10,12 +10,10 @@ package com.nis.util.httpclient;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.nis.util.JsonMapper;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
@@ -26,7 +24,10 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nis.util.JsonMapper;
|
||||
|
||||
/**
|
||||
* @ClassName: HttpClientBean.java
|
||||
@@ -36,7 +37,7 @@ import org.apache.log4j.Logger;
|
||||
* @version V1.0
|
||||
*/
|
||||
public class HttpClientUtil {
|
||||
protected final Logger logger = Logger.getLogger(HttpClientUtil.class);
|
||||
protected static final Logger logger =LoggerFactory.getLogger(HttpClientUtil.class);
|
||||
/**
|
||||
* 处理get请求.
|
||||
* @param url 请求路径
|
||||
|
||||
@@ -18,7 +18,8 @@ import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
|
||||
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nis.util.BeanHelper;
|
||||
import com.nis.util.Configurations;
|
||||
@@ -37,7 +38,7 @@ import redis.clients.jedis.JedisPool;
|
||||
* @version V1.0
|
||||
*/
|
||||
public class RedisDao {
|
||||
protected final Logger logger = Logger.getLogger(RedisDao.class);
|
||||
protected static final Logger logger =LoggerFactory.getLogger(RedisDao.class);
|
||||
private JedisCluster cluster=null;
|
||||
private JedisClusterPipeline jcp=null;
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@ package com.nis.util.redis;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
public class SaveRedisListThread extends Thread {
|
||||
private static RedisDao redisDao = SpringContextHolder.getBean(RedisDao.class);
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
protected static final Logger logger =LoggerFactory.getLogger(SaveRedisListThread.class);
|
||||
|
||||
private String key;
|
||||
private List<String> value;
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
package com.nis.util.redis;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.redis.RedisDao;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
public class SaveRedisThread extends Thread {
|
||||
private static RedisDao redisDao = SpringContextHolder.getBean(RedisDao.class);
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
|
||||
protected static final Logger logger =LoggerFactory.getLogger(SaveRedisThread.class);
|
||||
private String key;
|
||||
private Object value;
|
||||
private int expire;
|
||||
|
||||
@@ -7,7 +7,8 @@ import java.util.Date;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.ui.Model;
|
||||
@@ -29,62 +30,60 @@ import com.nis.web.service.SystemService;
|
||||
import com.nis.web.service.UserService;
|
||||
|
||||
public class BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
protected UserService userService;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected SystemService systemService;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected OfficeService officeService;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected AreaService areaService;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected RoleService roleService;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected MenuService menuService;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected LogService logService;
|
||||
|
||||
|
||||
@Autowired
|
||||
protected SwaggerLogService swaggerLogService;
|
||||
|
||||
@Autowired
|
||||
|
||||
@Autowired
|
||||
protected ArchiveServcie archiveServcie;
|
||||
|
||||
@Autowired
|
||||
|
||||
@Autowired
|
||||
protected DictService dictService;
|
||||
|
||||
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
|
||||
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(BaseController.class);
|
||||
|
||||
/**
|
||||
* 管理基础路径
|
||||
*/
|
||||
@Value("${adminPath}")
|
||||
protected String adminPath;
|
||||
|
||||
|
||||
/**
|
||||
* 前端基础路径
|
||||
*/
|
||||
@Value("${frontPath}")
|
||||
protected String frontPath;
|
||||
|
||||
|
||||
/**
|
||||
* 前端URL后缀
|
||||
*/
|
||||
@Value("${urlSuffix}")
|
||||
protected String urlSuffix;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 客户端返回JSON字符串
|
||||
*
|
||||
* @param response
|
||||
* @param object
|
||||
* @return
|
||||
@@ -92,10 +91,10 @@ public class BaseController {
|
||||
protected String renderString(HttpServletResponse response, Object object) {
|
||||
return renderString(response, JsonMapper.toJsonString(object), "application/json");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 客户端返回字符串
|
||||
*
|
||||
* @param response
|
||||
* @param string
|
||||
* @return
|
||||
@@ -103,44 +102,43 @@ public class BaseController {
|
||||
protected String renderString(HttpServletResponse response, String string, String type) {
|
||||
try {
|
||||
response.reset();
|
||||
response.setContentType(type);
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setContentType(type);
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.getWriter().print(string);
|
||||
return null;
|
||||
} catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 添加Model消息
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
protected void addMessage(Model model, String... messages) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String message : messages){
|
||||
sb.append(message).append(messages.length>1?"<br/>":"");
|
||||
for (String message : messages) {
|
||||
sb.append(message).append(messages.length > 1 ? "<br/>" : "");
|
||||
}
|
||||
model.addAttribute("message", sb.toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加Flash消息
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
protected void addMessage(RedirectAttributes redirectAttributes, String... messages) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String message : messages){
|
||||
sb.append(message).append(messages.length>1?"<br/>":"");
|
||||
for (String message : messages) {
|
||||
sb.append(message).append(messages.length > 1 ? "<br/>" : "");
|
||||
}
|
||||
redirectAttributes.addFlashAttribute("message", sb.toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 初始化数据绑定
|
||||
* 1. 将所有传递进来的String进行HTML编码,防止XSS攻击
|
||||
* 2. 将字段中Date类型转换为String类型
|
||||
* 初始化数据绑定 1. 将所有传递进来的String进行HTML编码,防止XSS攻击 2. 将字段中Date类型转换为String类型
|
||||
*/
|
||||
@InitBinder
|
||||
protected void initBinder(WebDataBinder binder) {
|
||||
@@ -150,6 +148,7 @@ public class BaseController {
|
||||
public void setAsText(String text) {
|
||||
setValue(text == null ? null : StringEscapeUtils.escapeHtml4(text.trim()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAsText() {
|
||||
Object value = getValue();
|
||||
@@ -164,8 +163,5 @@ public class BaseController {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ import com.zdjizhi.utils.StringUtil;
|
||||
* @version V1.0
|
||||
*/
|
||||
public class BaseRestController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
protected static final Logger logger =LoggerFactory.getLogger(BaseRestController.class);
|
||||
private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,8 +6,8 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.nis.web.service.AuditLogThread;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -20,13 +20,13 @@ import com.nis.listener.SystemConfigListener;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.controller.BaseRestController;
|
||||
import com.nis.web.service.AuditLogThread;
|
||||
import com.nis.web.service.ServicesRequestLogService;
|
||||
import com.nis.web.service.restful.DataDictionaryService;
|
||||
|
||||
@RestController
|
||||
//@RequestMapping("${servicePath}")
|
||||
public class DataDictionaryController extends BaseRestController {
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
@Autowired
|
||||
private DataDictionaryService dataDictionaryService;
|
||||
@Autowired
|
||||
@@ -47,7 +47,7 @@ public class DataDictionaryController extends BaseRestController {
|
||||
try {
|
||||
dataDictPage = dataDictionaryService.getDataDictList(page, dataDictionaryValue);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error(e.getMessage());
|
||||
throw new RestServiceException(thread, start, "数据字典获取失败");
|
||||
}
|
||||
return serviceResponse(thread, start, request, response, "编译配置获取成功", dataDictPage);
|
||||
@@ -62,7 +62,7 @@ public class DataDictionaryController extends BaseRestController {
|
||||
return serviceResponse(thread, start, request, response, "编译配置获取成功",
|
||||
dataDictionaryService.getDataDictList());
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error(e.getMessage());
|
||||
throw new RestServiceException(thread, start, "数据字典获取失败");
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class DataDictionaryController extends BaseRestController {
|
||||
}
|
||||
return serviceResponse(thread, start, request, response, "添加数据字典成功", "ok");
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error(e.getMessage());
|
||||
throw new RestServiceException(thread, start, "添加数据字典失败");
|
||||
}
|
||||
|
||||
@@ -107,7 +107,7 @@ public class DataDictionaryController extends BaseRestController {
|
||||
}
|
||||
return serviceResponse(thread, start, request, response, "删除数据字典值成功", "ok");
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error(e.getMessage());
|
||||
throw new RestServiceException(thread, start, "删除数据字典值失败");
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ public class DataDictionaryController extends BaseRestController {
|
||||
}
|
||||
return serviceResponse(thread, start, request, response, "删除数据字典名称成功", "ok");
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error(e.getMessage());
|
||||
throw new RestServiceException(thread, start, "删除数据字典名称失败");
|
||||
}
|
||||
}
|
||||
@@ -148,7 +148,7 @@ public class DataDictionaryController extends BaseRestController {
|
||||
// }
|
||||
// return "/test/page/dataDict/addOrUpdateDataDict.jsp";
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error(e.getMessage());
|
||||
throw new RestServiceException(thread, start, "获取数据字典对象失败");
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class DataDictionaryController extends BaseRestController {
|
||||
}
|
||||
return serviceResponse(thread, start, request, response, "修改数据字典成功", "ok");
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error(e.getMessage());
|
||||
throw new RestServiceException(thread, start, "修改数据字典失败");
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public class DataDictionaryController extends BaseRestController {
|
||||
}
|
||||
return serviceResponse(thread, start, request, response, "数据字典更新成功", "ok");
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
logger.error(e.getMessage());
|
||||
throw new RestServiceException(thread, start, "数据字典更新失败");
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
package com.nis.web.controller.restful;
|
||||
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -29,7 +30,7 @@ import com.nis.web.service.restful.ControlLogService;
|
||||
/*@RestController
|
||||
@RequestMapping("${servicePath}")*/
|
||||
public class ServiceController extends BaseRestController{
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
protected static final Logger logger =LoggerFactory.getLogger(ServiceController.class);
|
||||
@Autowired
|
||||
protected ControlLogService logService;
|
||||
|
||||
|
||||
@@ -5,9 +5,8 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.nis.web.service.AuditLogThread;
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -21,9 +20,11 @@ import com.nis.restful.RestServiceException;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.OracleErrorCodeUtil;
|
||||
import com.nis.web.controller.BaseRestController;
|
||||
import com.nis.web.service.AuditLogThread;
|
||||
import com.nis.web.service.ServicesRequestLogService;
|
||||
import com.nis.web.service.restful.SystemFunStatusService;
|
||||
import com.wordnik.swagger.annotations.ApiOperation;
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
|
||||
/**
|
||||
* @ClassName: SystemFunStatusController.java
|
||||
@@ -36,8 +37,7 @@ import com.wordnik.swagger.annotations.ApiOperation;
|
||||
//@RequestMapping("${servicePath}/cfg/v1")
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class SystemFunStatusController extends BaseRestController {
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
|
||||
private static final Logger logger =LoggerFactory.getLogger(SystemFunStatusController.class);
|
||||
|
||||
@Autowired
|
||||
protected SystemFunStatusService systemFunStatusService;
|
||||
@@ -70,7 +70,6 @@ public class SystemFunStatusController extends BaseRestController {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
e.printStackTrace();
|
||||
logger.error(e.getMessage());
|
||||
logger.error(e.getCause());
|
||||
if(e instanceof RestServiceException) {throw e;}
|
||||
String info=OracleErrorCodeUtil.getOraCode(e);
|
||||
if(!StringUtil.isEmpty(info)) {
|
||||
@@ -111,7 +110,6 @@ public class SystemFunStatusController extends BaseRestController {
|
||||
thread.setExceptionInfo(e.getMessage()+" "+e.getCause());
|
||||
e.printStackTrace();
|
||||
logger.error(e.getMessage());
|
||||
logger.error(e.getCause());
|
||||
if(e instanceof RestServiceException) {throw e; }
|
||||
String info=OracleErrorCodeUtil.getOraCode(e);
|
||||
if(!StringUtil.isEmpty(info)) {
|
||||
|
||||
@@ -21,7 +21,8 @@ import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.nis.datasource.CustomerContextHolder;
|
||||
|
||||
@@ -34,7 +35,7 @@ import com.nis.datasource.CustomerContextHolder;
|
||||
* @version V1.0
|
||||
*/
|
||||
public class AuditLogThread implements Runnable {
|
||||
private Logger logger = Logger.getLogger(AuditLogThread.class);
|
||||
private Logger logger =LoggerFactory.getLogger(AuditLogThread.class);
|
||||
private ServicesRequestLogService service;
|
||||
private String remoteAddr;
|
||||
private String requestURI;
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
package com.nis.web.service;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.ibatis.mapping.ResultMap;
|
||||
import org.apache.ibatis.mapping.ResultMapping;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.nis.domain.LogEntity;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.NtcCollectVoipLog;
|
||||
@@ -13,19 +29,6 @@ import com.nis.util.elasticsearch.ElasticsearchSqlDao;
|
||||
import com.zdjizhi.utils.DateUtils;
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
import com.zdjizhi.utils.TimeConstants;
|
||||
import org.apache.ibatis.mapping.ResultMap;
|
||||
import org.apache.ibatis.mapping.ResultMapping;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 基础日志Service基类
|
||||
@@ -36,7 +39,9 @@ import java.util.Map;
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
public abstract class BaseLogService {
|
||||
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
|
||||
|
||||
protected static final Logger logger =LoggerFactory.getLogger(BaseLogService.class);
|
||||
@Autowired
|
||||
protected ElasticsearchSqlDao elasticsearchSqlDao;
|
||||
|
||||
|
||||
@@ -26,7 +26,8 @@ import java.util.regex.Pattern;
|
||||
|
||||
import org.apache.ibatis.mapping.ResultMapping;
|
||||
import org.apache.ibatis.session.SqlSessionFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -47,7 +48,8 @@ import com.nis.web.dao.ServicesRequestLogDao;
|
||||
*/
|
||||
@Service
|
||||
public class ServicesRequestLogService {
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(ServicesRequestLogService.class);
|
||||
@Autowired
|
||||
public ServicesRequestLogDao servicesRequestLogDao;
|
||||
|
||||
@@ -57,38 +59,25 @@ public class ServicesRequestLogService {
|
||||
} else {
|
||||
servicesRequestLogDao.insertLogLog(log);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* saveRequestLog(记录请求日志) (这里描述这个方法适用条件 – 可选)
|
||||
*
|
||||
* @param requestAddr
|
||||
* request中的参数
|
||||
* @param requestURI
|
||||
* request中的参数
|
||||
* @param queryString
|
||||
* request中的参数
|
||||
* @param contextPath
|
||||
* request中的参数 响应
|
||||
* @param operator
|
||||
* 操作人
|
||||
* @param version
|
||||
* 版本
|
||||
* @param opAction
|
||||
* 操作行为
|
||||
* @param opTime
|
||||
* 操作时间
|
||||
* @param content
|
||||
* 请求体
|
||||
* @param requestTime
|
||||
* 请求到达服务器时间
|
||||
* @param consumerTime
|
||||
* 耗时 void
|
||||
* @param requestAddr request中的参数
|
||||
* @param requestURI request中的参数
|
||||
* @param queryString request中的参数
|
||||
* @param contextPath request中的参数 响应
|
||||
* @param operator 操作人
|
||||
* @param version 版本
|
||||
* @param opAction 操作行为
|
||||
* @param opTime 操作时间
|
||||
* @param content 请求体
|
||||
* @param requestTime 请求到达服务器时间
|
||||
* @param consumerTime 耗时 void
|
||||
* @throws UnknownHostException
|
||||
* @exception @since
|
||||
* 1.0.0
|
||||
* @exception @since 1.0.0
|
||||
*/
|
||||
public void saveRequestLog(String requestAddr, String requestURI, String queryString, String contextPath,
|
||||
String operator, String version, int opAction, Date opTime, Object content, Date requestTime,
|
||||
@@ -199,10 +188,8 @@ public class ServicesRequestLogService {
|
||||
*
|
||||
* @param data
|
||||
* @throws IllegalArgumentException
|
||||
* @throws IllegalAccessException
|
||||
* void
|
||||
* @exception @since
|
||||
* 1.0.0
|
||||
* @throws IllegalAccessException void
|
||||
* @exception @since 1.0.0
|
||||
*/
|
||||
public void save(ServicesRequestLog data) throws IllegalArgumentException, IllegalAccessException {
|
||||
SqlSessionFactory sqlSessionFactory = SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
|
||||
@@ -440,6 +440,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
|
||||
@Override
|
||||
public boolean saveMaatConfig(Map<Integer, List<MaatConfig>> configMap) {
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
|
||||
if (configMap != null && configMap.size() > 0) {
|
||||
int count = 0;
|
||||
Jedis resource = JedisUtils.getResource(0);
|
||||
@@ -492,6 +494,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
addMaatRelation(configMap, transaction);
|
||||
addStatisticsReal(configMap, transaction);
|
||||
transaction.exec();
|
||||
long end = System.currentTimeMillis();
|
||||
logger.warn("执行ConfigJedisServiceImpl.saveMaatConfig用时{}毫秒", end - currentTimeMillis);
|
||||
return true;
|
||||
} else {
|
||||
transaction.discard();
|
||||
@@ -936,10 +940,12 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
|
||||
}
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
"未从" + idRelaRedisDBIndex + "号redis库(编译,分组,域关系)中获取配置compileId=" + configId
|
||||
+ ",对应的redisdb信息,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常",
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
// throw new ServiceRuntimeException(
|
||||
// "未从" + idRelaRedisDBIndex + "号redis库(编译,分组,域关系)中获取配置compileId=" + configId
|
||||
// + ",对应的redisdb信息,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常",
|
||||
// RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
logger.error("不存在的配置id{}", configId);
|
||||
|
||||
}
|
||||
// }
|
||||
}
|
||||
@@ -1011,11 +1017,11 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
list.add(i);
|
||||
}
|
||||
serviceConfigMap.put(129, list);
|
||||
delMaatConfig(serviceConfigMap,false);
|
||||
delMaatConfig(serviceConfigMap, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delMaatConfig(Map<Integer, List<Long>> serviceConfigMap,boolean isStart) {
|
||||
public boolean delMaatConfig(Map<Integer, List<Long>> serviceConfigMap, boolean isStart) {
|
||||
if (serviceConfigMap != null && serviceConfigMap.size() > 0) {
|
||||
Jedis resource = JedisUtils.getResource(0);
|
||||
Transaction transaction = resource.multi();
|
||||
@@ -1036,7 +1042,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
// 按序号选择Redis数据库
|
||||
transaction.select(redisDb);
|
||||
removeConfig(id, maatXmlConfig, maatVersion, service, transaction, redisDb,
|
||||
idRelaRedisDBIndex,isStart);
|
||||
idRelaRedisDBIndex, isStart);
|
||||
}
|
||||
} else {
|
||||
throw new ServiceRuntimeException("删除配置时,未发现对应的配置id信息,请检查配置参数是否正确",
|
||||
@@ -1090,8 +1096,6 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取关联关系中每个关系中的-前部分
|
||||
*
|
||||
@@ -1115,7 +1119,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
* @param service 业务类型
|
||||
* @param redisTemplate
|
||||
* @param maatRelation id对应关系对象
|
||||
* @param isStart 是否将配置置为生效
|
||||
* @param isStart 是否将配置置为生效
|
||||
*/
|
||||
private void removeConfig(Long id, MaatXmlConfig maatXmlConfig, Double maatVersion, int service,
|
||||
Transaction transaction, int redisDBIndex, int idRelaRedisDBIndex, boolean isStart) {
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -27,8 +26,6 @@ import com.zdjizhi.utils.StringUtil;
|
||||
*/
|
||||
@Service
|
||||
public class ConfigPzIdService extends BaseLogService {
|
||||
|
||||
protected final Logger logger = Logger.getLogger(this.getClass());
|
||||
/**
|
||||
* 持久层对象
|
||||
*/
|
||||
|
||||
@@ -122,6 +122,8 @@ public class ConfigSourcesService extends BaseService {
|
||||
*/
|
||||
public void saveMaatConfig(AuditLogThread thread, long start, List<ConfigCompile> configCompileList,
|
||||
StringBuffer sb) throws Exception {
|
||||
|
||||
long currentTimeMillis = System.currentTimeMillis();
|
||||
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
|
||||
Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>();
|
||||
|
||||
@@ -207,7 +209,6 @@ public class ConfigSourcesService extends BaseService {
|
||||
}
|
||||
}
|
||||
maatConfig.setIpClientRangeMapList(dstMaplList);
|
||||
|
||||
if (maatMap.containsKey(service)) {
|
||||
maatMap.get(service).add(maatConfig);
|
||||
} else {
|
||||
@@ -254,6 +255,9 @@ public class ConfigSourcesService extends BaseService {
|
||||
}
|
||||
}
|
||||
logger.info("---------------调用Redis maat配置新增接口---------------------");
|
||||
|
||||
long end = System.currentTimeMillis();
|
||||
logger.warn("执行ConfigSourcesService.saveMaatConfig用时{}毫秒",end-currentTimeMillis);
|
||||
configRedisService.saveMaatConfig(configMap);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,12 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.DataDictionaryName;
|
||||
import com.nis.domain.restful.DataDictionaryValue;
|
||||
@@ -14,7 +17,7 @@ import com.nis.web.dao.DataDictionaryDao;
|
||||
|
||||
@Service
|
||||
public class DataDictionaryService {
|
||||
protected final Logger logger1 = Logger.getLogger(this.getClass());
|
||||
protected final Logger logger = LoggerFactory.getLogger(DataDictionaryService.class);
|
||||
@Autowired
|
||||
private DataDictionaryDao dataDictionaryDao;
|
||||
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.restful.EventKeyProtection;
|
||||
import com.nis.domain.restful.EventMonitorOrBlock;
|
||||
import com.nis.util.CalendarUtils;
|
||||
import com.nis.util.DateUtils;
|
||||
import com.nis.web.dao.EventServiceDao;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author GouGe
|
||||
@@ -24,8 +26,7 @@ import java.util.List;
|
||||
public class EventService {
|
||||
@Autowired
|
||||
EventServiceDao eventServiceDao;
|
||||
|
||||
protected final Logger logger = Logger.getLogger(SystemHomePageService.class);
|
||||
protected final Logger logger = LoggerFactory.getLogger(EventService.class);
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,7 +11,8 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -30,7 +31,9 @@ public class SystemHomePageService {
|
||||
@Autowired
|
||||
SystemHomePageDao systemHomePageDao;
|
||||
|
||||
protected final Logger logger = Logger.getLogger(SystemHomePageService.class);
|
||||
protected final Logger logger =LoggerFactory.getLogger(SystemHomePageService.class);
|
||||
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
// 获取地域流量
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
package com.nis.web.task;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.ServiceRuntimeException;
|
||||
import com.nis.util.Configurations;
|
||||
@@ -8,16 +23,16 @@ import com.nis.util.ExceptionUtil;
|
||||
import com.nis.util.JedisUtils;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
import com.nis.web.service.restful.ConfigJedisServiceimpl;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import redis.clients.jedis.*;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisCluster;
|
||||
import redis.clients.jedis.JedisPool;
|
||||
import redis.clients.jedis.ScanParams;
|
||||
import redis.clients.jedis.ScanResult;
|
||||
import redis.clients.jedis.Tuple;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
import redis.clients.util.JedisClusterCRC16;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Component
|
||||
@PropertySource(value = { "classpath:nis.properties", "classpath:jdbc.properties" })
|
||||
public class SyncRedisToCluster {
|
||||
@@ -57,7 +72,7 @@ public class SyncRedisToCluster {
|
||||
}
|
||||
}
|
||||
|
||||
//@Scheduled(cron = "${syncRedisToClusterCron}")
|
||||
// @Scheduled(cron = "${syncRedisToClusterCron}")
|
||||
public void syncRedisToCluster() {
|
||||
JedisCluster jedisCluster = getResource();
|
||||
String requestId = UUID.randomUUID().toString();
|
||||
|
||||
@@ -69,7 +69,6 @@ public class HelloWorldController extends BaseController{
|
||||
|
||||
@RequestMapping("/testPathVariable/{id}")
|
||||
public String testPathVariable(@PathVariable("id") int id){
|
||||
logger.info(id);
|
||||
return "success";
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#Log4j
|
||||
log4j.rootLogger=info,console,file
|
||||
# 控制台日志设置
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.console.Threshold=info
|
||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.console.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] [%-5p] [Thread\:%t] %l %x - <%m>%n
|
||||
|
||||
# 文件日志设置
|
||||
log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.file.Threshold=info
|
||||
log4j.appender.file.encoding=UTF-8
|
||||
log4j.appender.file.Append=true
|
||||
#tomcat启动时首先判断CATALINA_HOME环境变量是否为空,如果为空,就将当前目录设为CATALINA_HOME的值,所以这里log4j可以直接使用环境变量的值
|
||||
log4j.appender.file.file=${catalina.home}/logs/nis.log
|
||||
log4j.appender.file.DatePattern='.'yyyy-MM-dd
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
#log4j.appender.file.layout.ConversionPattern=%d{HH:mm:ss} %X{ip} [%t] %5p %c{1} %m%n
|
||||
log4j.appender.file.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] [%-5p] %X{ip} [Thread\:%t] %l %x - %m%n
|
||||
#MyBatis 配置,com.nis.web.dao是mybatis接口所在包
|
||||
log4j.logger.com.nis.web.dao=debug
|
||||
#bonecp数据源配置
|
||||
log4j.category.com.jolbox=debug,console
|
||||
93
src/main/resources/log4j2.xml
Normal file
93
src/main/resources/log4j2.xml
Normal file
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- xml声明 -->
|
||||
<!-- 大小写不敏感 -->
|
||||
<!-- configuration后面的status,这个用于设置log4j2自身内部的信息输出,可以不设置,当设置成trace时,你会看到log4j2内部各种详细输出 -->
|
||||
<configuration status="error">
|
||||
<!-- 常见的有三种子节点:Console、RollingFile、File. -->
|
||||
<appenders>
|
||||
<!-- Console节点用来定义输出到控制台的Appender,name:指定Appender的名字,target:SYSTEM_OUT
|
||||
或 SYSTEM_ERR,一般只设置默认:SYSTEM_OUT -->
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<!-- 控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch),注意如果需要打印mybatis的sql语句,console的level一定要比debug级别低,一般这里不设置了 -->
|
||||
<!-- <ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY" /> -->
|
||||
<PatternLayout
|
||||
pattern="%d{yyyy-MM-dd HH:mm:ss.SSS} [%p]-[%l]-[%msg]%n" />
|
||||
</Console>
|
||||
|
||||
<!--file节点文件会打印出所有信息,这个log每次运行程序会自动清空,由append属性决定,这个也挺有用的,适合临时测试用 -->
|
||||
<File name="log" fileName="${sys:catalina.home}/logs/test.log" append="false">
|
||||
<PatternLayout
|
||||
pattern="%d{HH:mm:ss.SSS} %-5level %class{36} %L %M - %msg%xEx%n" />
|
||||
</File>
|
||||
<!-- 这个会打印出所有的info及以下级别的信息,每次大小超过size,则这size大小的日志会自动存入按年份-月份建立的文件夹下面并进行压缩,作为存档 -->
|
||||
<RollingFile name="RollingFileInfo"
|
||||
fileName="${sys:catalina.home}/logs/info.log"
|
||||
filePattern="${sys:catalina.home}/logs/$${date:yyyy-MM}/info-%d{yyyy-MM-dd}-%i.log">
|
||||
<!--控制台只输出level及以上级别的信息(onMatch),其他的直接拒绝(onMismatch) -->
|
||||
<ThresholdFilter level="info" onMatch="ACCEPT"
|
||||
onMismatch="DENY" />
|
||||
<PatternLayout
|
||||
pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="100 MB" />
|
||||
</Policies>
|
||||
</RollingFile>
|
||||
<RollingFile name="RollingFileWarn"
|
||||
fileName="${sys:catalina.home}/logs/warn.log"
|
||||
filePattern="${sys:catalina.home}/logs/$${date:yyyy-MM}/warn-%d{yyyy-MM-dd}-%i.log">
|
||||
<ThresholdFilter level="warn" onMatch="ACCEPT"
|
||||
onMismatch="DENY" />
|
||||
<PatternLayout
|
||||
pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="100 MB" />
|
||||
</Policies>
|
||||
<!-- DefaultRolloverStrategy属性如不设置,则默认为最多同一文件夹下7个文件,这里设置了20 -->
|
||||
<DefaultRolloverStrategy max="20" />
|
||||
</RollingFile>
|
||||
<RollingFile name="RollingFileError"
|
||||
fileName="${sys:catalina.home}/logs/error.log"
|
||||
filePattern="${sys:catalina.home}/logs/$${date:yyyy-MM}/error-%d{yyyy-MM-dd}-%i.log">
|
||||
<ThresholdFilter level="error" onMatch="ACCEPT"
|
||||
onMismatch="DENY" />
|
||||
<PatternLayout
|
||||
pattern="[%d{HH:mm:ss:SSS}] [%p] - %l - %m%n" />
|
||||
<Policies>
|
||||
<TimeBasedTriggeringPolicy />
|
||||
<SizeBasedTriggeringPolicy size="100 MB" />
|
||||
</Policies>
|
||||
</RollingFile>
|
||||
</appenders>
|
||||
|
||||
|
||||
|
||||
<Loggers>
|
||||
<!-- level是日志记录的优先级,分为OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、 ALL等或者自己定义的级别。 -->
|
||||
<!-- ALL:是最低等级的,用于打开所有日志记录 -->
|
||||
<!-- OFF:是最高等级的,用于关闭所有日志记录 -->
|
||||
<!-- FATAL:指出每个严重的错误事件将会导致应用程序的退出 -->
|
||||
<!-- Log4j建议只使用四个级别,优先级从高到低分别是ERROR、WARN、INFO、DEBUG -->
|
||||
<!-- 级别之间是包含的关系,意思是如果你设置日志级别是trace,则大于等于这个级别的日志都会输出 -->
|
||||
<!--分别定义不同的包用不同的日志 方便大型项目调试 -->
|
||||
<!-- 因为是控制台打印,如果additivity不设置默认值是为true 会在控制台打印两次信息 -->
|
||||
<!-- additivity如果设置为true将会输出两次日志,其中一次是继承了root的日志配置输出信息 就算你没写root 它也会继承不知从哪里来的root打印一次 -->
|
||||
|
||||
<!-- 设置mybatis打印sql语句的支持,name中的值为mybatis的DAO层接口包路径,注意别忘了在mybatis-config.xml中配置<setting name="logImpl" value="LOG4J2" />,否则这里不生效 -->
|
||||
<logger name="com.nis.web.dao" level="debug" additivity="false">
|
||||
<appender-ref ref="Console" />
|
||||
</logger>
|
||||
|
||||
<!--过滤掉spring和mybatis的一些无用的DEBUG信息 -->
|
||||
<logger name="org.springframework" level="INFO"></logger>
|
||||
<logger name="org.mybatis" level="INFO"></logger>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="Console" />
|
||||
<appender-ref ref="RollingFileInfo" />
|
||||
<appender-ref ref="RollingFileWarn" />
|
||||
<appender-ref ref="RollingFileError" />
|
||||
</root>
|
||||
</Loggers>
|
||||
</configuration>
|
||||
@@ -47,7 +47,7 @@
|
||||
<!-- 设置但JDBC类型为空时,某些驱动程序 要指定值,default:OTHER,插入空值时不需要指定类型 -->
|
||||
<setting name="jdbcTypeForNull" value="NULL" />
|
||||
<!-- 打印查询语句 -->
|
||||
<setting name="logImpl" value="STDOUT_LOGGING" />
|
||||
<setting name="logImpl" value="LOG4J2" />
|
||||
</settings>
|
||||
|
||||
<!--通过指定包名设置,在相关映射时可使用不带包的简短名字:bean的首字母小写作为默认别名 -->
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
<!-- 让web应用程序启动那个时自动添加属性文件 -->
|
||||
<context-param>
|
||||
<param-name>log4jConfigLocation</param-name>
|
||||
<param-value>classpath:log4j.properties</param-value>
|
||||
<param-value>classpath:log4j2.xml</param-value>
|
||||
</context-param>
|
||||
|
||||
<context-param>
|
||||
|
||||
Reference in New Issue
Block a user