Merge pull request #407 from shangxiaobin/master

"修复打印有参日志时报错的问题"

赞!这种方式确实兼容性更好,更加优雅!
pull/MERGE
许雪里 7 years ago committed by GitHub
commit eb850d76ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

Loading…
Cancel
Save