[Optimize]日志统一格式&优化输出内容-part3(#800)

This commit is contained in:
zengqiao
2022-12-02 15:14:21 +08:00
parent 7a52cf67b0
commit fab41e892f
30 changed files with 84 additions and 84 deletions

View File

@@ -1,7 +1,7 @@
package com.xiaojukeji.know.streaming.km.persistence.es;
import com.didiglobal.logi.log.ILog;
import com.didiglobal.logi.log.LogFactory;
import com.xiaojukeji.know.streaming.km.common.utils.LoggerUtil;
import com.xiaojukeji.know.streaming.km.persistence.es.dsls.DslLoaderUtil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
* 直接操作es集群的dao
*/
public abstract class BaseESDAO {
protected static final ILog LOGGER = LogFactory.getLog("ES_LOGGER");
protected static final ILog LOGGER = LoggerUtil.getESLogger();
/**
* 加载查询语句工具类

View File

@@ -65,7 +65,7 @@ public class BaseMetricESDAO extends BaseESDAO {
esOpClient.createIndex(realIndex);
}
}catch (Exception e){
} catch (Exception e) {
LOGGER.error("method=checkCurrentDayIndexExist||errMsg=exception!", e);
}
}

View File

@@ -59,7 +59,7 @@ public class ZookeeperMetricESDAO extends BaseMetricESDAO {
ESConstant.DEFAULT_RETRY_TIME
);
} catch (Exception e){
LOGGER.error("class=ZookeeperMetricESDAO||method=listMetricsByClusterPhyId||clusterPhyId={}||errMsg=exception!",
LOGGER.error("method=listMetricsByClusterPhyId||clusterPhyId={}||errMsg=exception!",
clusterPhyId, e
);
}

View File

@@ -7,10 +7,10 @@ import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.parser.ParserConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.didiglobal.logi.log.ILog;
import com.didiglobal.logi.log.LogFactory;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.xiaojukeji.know.streaming.km.common.utils.EnvUtil;
import com.xiaojukeji.know.streaming.km.common.utils.LoggerUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
@@ -34,7 +34,7 @@ import java.util.Map;
*/
@Component
public class DslLoaderUtil {
private static final ILog LOGGER = LogFactory.getLog("ES_LOGGER");
private static final ILog LOGGER = LoggerUtil.getESLogger();
/**
* 查询语句容器
*/
@@ -42,7 +42,7 @@ public class DslLoaderUtil {
@PostConstruct
public void init() {
LOGGER.info("class=DslLoaderUtil||method=init||DslLoaderUtil init start.");
LOGGER.info("method=init||DslLoaderUtil init start.");
List<String> dslFileNames = Lists.newLinkedList();
// 反射获取接口中定义的变量中的值
@@ -52,7 +52,7 @@ public class DslLoaderUtil {
try {
dslFileNames.add(fields[i].get(null).toString());
} catch (IllegalAccessException e) {
LOGGER.error("class=DslLoaderUtil||method=init||errMsg=fail to read {} error. ", fields[i].getName(),
LOGGER.error("method=init||errMsg=fail to read {} error. ", fields[i].getName(),
e);
}
}
@@ -63,13 +63,13 @@ public class DslLoaderUtil {
}
// 输出加载的查询语句
LOGGER.info("class=DslLoaderUtil||method=init||msg=dsl files count {}", dslsMap.size());
LOGGER.info("method=init||msg=dsl files count {}", dslsMap.size());
for (Map.Entry<String/*fileRelativePath*/, String/*dslContent*/> entry : dslsMap.entrySet()) {
LOGGER.info("class=DslLoaderUtil||method=init||msg=file name {}, dsl content {}", entry.getKey(),
LOGGER.info("method=init||msg=file name {}, dsl content {}", entry.getKey(),
entry.getValue());
}
LOGGER.info("class=DslLoaderUtil||method=init||DslLoaderUtil init finished.");
LOGGER.info("method=init||DslLoaderUtil init finished.");
}
/**
@@ -93,7 +93,7 @@ public class DslLoaderUtil {
String loadDslContent = getDslByFileName(fileName);
if (StringUtils.isBlank(loadDslContent)) {
LOGGER.error("class=DslLoaderUtil||method=getFormatDslByFileName||errMsg=dsl file {} content is empty",
LOGGER.error("method=getFormatDslByFileName||errMsg=dsl file {} content is empty",
fileName);
return "";
}
@@ -102,7 +102,7 @@ public class DslLoaderUtil {
String dsl = trimJsonBank( String.format(loadDslContent, args));
// 如果不是线上环境则输出dsl语句
if (!EnvUtil.isOnline()) {
LOGGER.info("class=DslLoaderUtil||method=getFormatDslByFileName||dsl={}", dsl);
LOGGER.info("method=getFormatDslByFileName||dsl={}", dsl);
}
return dsl;
@@ -164,7 +164,7 @@ public class DslLoaderUtil {
JSON.DEFAULT_PARSER_FEATURE | Feature.OrderedField.getMask());
obj = parser.parse();
} catch (Exception t) {
LOGGER.error("class=DslLoaderUtil||method=trimJsonBank||errMsg=parse json {} error. ", dsl, t);
LOGGER.error("method=trimJsonBank||errMsg=parse json {} error. ", dsl, t);
}
if (obj == null) {
break;
@@ -212,7 +212,7 @@ public class DslLoaderUtil {
return StringUtils.join(lines, "");
} catch (IOException e) {
LOGGER.error("class=DslLoaderUtil||method=readDslFileInJarFile||errMsg=read file {} error. ", fileName,
LOGGER.error("method=readDslFileInJarFile||errMsg=read file {} error. ", fileName,
e);
return "";
@@ -221,12 +221,12 @@ public class DslLoaderUtil {
inputStream.close();
} catch (IOException e) {
LOGGER.error(
"class=DslLoaderUtil||method=readDslFileInJarFile||errMsg=fail to close file {} error. ",
"method=readDslFileInJarFile||errMsg=fail to close file {} error. ",
fileName, e);
}
}
} else {
LOGGER.error("class=DslLoaderUtil||method=readDslFileInJarFile||errMsg=fail to read file {} content",
LOGGER.error("method=readDslFileInJarFile||errMsg=fail to read file {} content",
fileName);
return "";
}

View File

@@ -65,7 +65,7 @@ public class JmxDAOImpl implements JmxDAO {
return object == null? null: (Long) object;
} catch (Exception e) {
log.error(
"class=JmxDAOImpl||method=getServerStartTime||clusterPhyId={}||jmxHost={}||jmxPort={}||jmxConfig={}||errMsg=exception!",
"method=getServerStartTime||clusterPhyId={}||jmxHost={}||jmxPort={}||jmxConfig={}||errMsg=exception!",
clusterPhyId, jmxHost, jmxPort, jmxConfig, e
);
}