Browse Source

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

xuxueli 7 years ago
parent
commit
3c21542269

+ 1 - 0
doc/XXL-JOB官方文档.md View File

1222
 - 13、任务线程停止变量修饰符优化;
1222
 - 13、任务线程停止变量修饰符优化;
1223
 - 14、脚本任务Log文件流关闭优化;
1223
 - 14、脚本任务Log文件流关闭优化;
1224
 - 15、任务报表成功、失败和进行中统计问题修复;
1224
 - 15、任务报表成功、失败和进行中统计问题修复;
1225
+- 16、自研Log组件参数占位符改为"{}",并修复打印有参日志时参数不匹配导致报错的问题;
1225
 
1226
 
1226
 
1227
 
1227
 ### TODO LIST
1228
 ### TODO LIST

+ 12 - 12
xxl-job-core/src/main/java/com/xxl/job/core/log/XxlJobLogger.java View File

1
 package com.xxl.job.core.log;
1
 package com.xxl.job.core.log;
2
 
2
 
3
-import java.io.PrintWriter;
4
-import java.io.StringWriter;
5
-import java.text.SimpleDateFormat;
6
-import java.util.Date;
7
-
8
 import org.slf4j.Logger;
3
 import org.slf4j.Logger;
9
 import org.slf4j.LoggerFactory;
4
 import org.slf4j.LoggerFactory;
10
 import org.slf4j.helpers.FormattingTuple;
5
 import org.slf4j.helpers.FormattingTuple;
11
 import org.slf4j.helpers.MessageFormatter;
6
 import org.slf4j.helpers.MessageFormatter;
12
 
7
 
8
+import java.io.PrintWriter;
9
+import java.io.StringWriter;
10
+import java.text.SimpleDateFormat;
11
+import java.util.Date;
12
+
13
 /**
13
 /**
14
  * Created by xuxueli on 17/4/28.
14
  * Created by xuxueli on 17/4/28.
15
  */
15
  */
50
     /**
50
     /**
51
      * append log with pattern
51
      * append log with pattern
52
      *
52
      *
53
-     * @param appendLogPattern  like "aaa {0} bbb {1} ccc"
53
+     * @param appendLogPattern  like "aaa {} bbb {} ccc"
54
      * @param appendLogArguments    like "111, true"
54
      * @param appendLogArguments    like "111, true"
55
      */
55
      */
56
     public static void log(String appendLogPattern, Object ... appendLogArguments) {
56
     public static void log(String appendLogPattern, Object ... appendLogArguments) {
57
 
57
 
58
     	FormattingTuple ft = MessageFormatter.format(appendLogPattern, appendLogArguments);
58
     	FormattingTuple ft = MessageFormatter.format(appendLogPattern, appendLogArguments);
59
-        
60
         String appendLog = ft.getMessage();
59
         String appendLog = ft.getMessage();
60
+
61
+        /*appendLog = appendLogPattern;
62
+        if (appendLogArguments!=null && appendLogArguments.length>0) {
63
+            appendLog = MessageFormat.format(appendLogPattern, appendLogArguments);
64
+        }*/
65
+
61
         StackTraceElement callInfo = new Throwable().getStackTrace()[1];
66
         StackTraceElement callInfo = new Throwable().getStackTrace()[1];
62
-        
63
-//        appendLog = appendLogPattern;
64
-//        if (appendLogArguments!=null && appendLogArguments.length>0) {
65
-//            appendLog = MessageFormat.format(appendLogPattern, appendLogArguments);
66
-//        }
67
         logDetail(callInfo, appendLog);
67
         logDetail(callInfo, appendLog);
68
     }
68
     }
69
 
69