自研Log组件参数占位符改为"{}",并修复打印有参日志时参数不匹配导致报错的问题;

This commit is contained in:
xuxueli 2018-06-24 15:44:37 +08:00
parent eb850d76ca
commit 3c21542269
2 changed files with 13 additions and 12 deletions

View File

@ -1222,6 +1222,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 13、任务线程停止变量修饰符优化 - 13、任务线程停止变量修饰符优化
- 14、脚本任务Log文件流关闭优化 - 14、脚本任务Log文件流关闭优化
- 15、任务报表成功、失败和进行中统计问题修复 - 15、任务报表成功、失败和进行中统计问题修复
- 16、自研Log组件参数占位符改为"{}",并修复打印有参日志时参数不匹配导致报错的问题;
### TODO LIST ### TODO LIST

View File

@ -1,15 +1,15 @@
package com.xxl.job.core.log; package com.xxl.job.core.log;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.slf4j.helpers.FormattingTuple; import org.slf4j.helpers.FormattingTuple;
import org.slf4j.helpers.MessageFormatter; import org.slf4j.helpers.MessageFormatter;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.SimpleDateFormat;
import java.util.Date;
/** /**
* Created by xuxueli on 17/4/28. * Created by xuxueli on 17/4/28.
*/ */
@ -50,20 +50,20 @@ public class XxlJobLogger {
/** /**
* append log with pattern * append log with pattern
* *
* @param appendLogPattern like "aaa {0} bbb {1} ccc" * @param appendLogPattern like "aaa {} bbb {} ccc"
* @param appendLogArguments like "111, true" * @param appendLogArguments like "111, true"
*/ */
public static void log(String appendLogPattern, Object ... appendLogArguments) { public static void log(String appendLogPattern, Object ... appendLogArguments) {
FormattingTuple ft = MessageFormatter.format(appendLogPattern, appendLogArguments); FormattingTuple ft = MessageFormatter.format(appendLogPattern, appendLogArguments);
String appendLog = ft.getMessage(); String appendLog = ft.getMessage();
StackTraceElement callInfo = new Throwable().getStackTrace()[1];
// appendLog = appendLogPattern; /*appendLog = appendLogPattern;
// if (appendLogArguments!=null && appendLogArguments.length>0) { if (appendLogArguments!=null && appendLogArguments.length>0) {
// appendLog = MessageFormat.format(appendLogPattern, appendLogArguments); appendLog = MessageFormat.format(appendLogPattern, appendLogArguments);
// } }*/
StackTraceElement callInfo = new Throwable().getStackTrace()[1];
logDetail(callInfo, appendLog); logDetail(callInfo, appendLog);
} }