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

pull/MERGE
xuxueli 7 years ago committed by shangxiaobin
parent 56232ef1c0
commit 1aac34165c

@ -1217,6 +1217,7 @@ Tips: 历史版本(V1.3.x)目前已经Release至稳定版本, 进入维护阶段
- 12、脚本任务异常Log输出优化 - 12、脚本任务异常Log输出优化
- 13、任务线程停止变量修饰符优化 - 13、任务线程停止变量修饰符优化
- 14、脚本任务Log文件流关闭优化 - 14、脚本任务Log文件流关闭优化
- 15、任务报表成功、失败和进行中统计问题修复
### TODO LIST ### TODO LIST

@ -56,21 +56,22 @@ public class JobFailMonitorHelper {
continue; continue;
} }
if (IJobHandler.SUCCESS.getCode() == log.getTriggerCode() && log.getHandleCode() == 0) { if (IJobHandler.SUCCESS.getCode() == log.getTriggerCode() && log.getHandleCode() == 0) {
// job running
JobFailMonitorHelper.monitor(jobLogId); JobFailMonitorHelper.monitor(jobLogId);
logger.info(">>>>>>>>>>> job monitor, job running, JobLogId:{}", jobLogId); logger.info(">>>>>>>>>>> job monitor, job running, JobLogId:{}", jobLogId);
} else if (IJobHandler.SUCCESS.getCode() == log.getHandleCode()) { } else if (IJobHandler.SUCCESS.getCode() == log.getHandleCode()) {
// job success, pass // job success, pass
logger.info(">>>>>>>>>>> job monitor, job success, JobLogId:{}", jobLogId); logger.info(">>>>>>>>>>> job monitor, job success, JobLogId:{}", jobLogId);
} else if (IJobHandler.FAIL.getCode() == log.getTriggerCode() } else /*if (IJobHandler.FAIL.getCode() == log.getTriggerCode()
|| IJobHandler.FAIL.getCode() == log.getHandleCode() || IJobHandler.FAIL.getCode() == log.getHandleCode()
|| IJobHandler.FAIL_RETRY.getCode() == log.getHandleCode() ) { || IJobHandler.FAIL_RETRY.getCode() == log.getHandleCode() )*/ {
// job fail, // job fail,
failAlarm(log); failAlarm(log);
logger.info(">>>>>>>>>>> job monitor, job fail, JobLogId:{}", jobLogId); logger.info(">>>>>>>>>>> job monitor, job fail, JobLogId:{}", jobLogId);
} else { }/* else {
JobFailMonitorHelper.monitor(jobLogId); JobFailMonitorHelper.monitor(jobLogId);
logger.info(">>>>>>>>>>> job monitor, job status unknown, JobLogId:{}", jobLogId); logger.info(">>>>>>>>>>> job monitor, job status unknown, JobLogId:{}", jobLogId);
} }*/
} }
} }

@ -172,7 +172,7 @@
SELECT SELECT
DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay, DATE_FORMAT(trigger_time,'%Y-%m-%d') triggerDay,
COUNT(handle_code) triggerDayCount, COUNT(handle_code) triggerDayCount,
SUM(CASE WHEN handle_code = 0 then 1 else 0 end) as triggerDayCountRunning, SUM(CASE WHEN (trigger_code = 200 and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning,
SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc
FROM XXL_JOB_QRTZ_TRIGGER_LOG FROM XXL_JOB_QRTZ_TRIGGER_LOG
WHERE trigger_time BETWEEN #{from} and #{to} WHERE trigger_time BETWEEN #{from} and #{to}

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

Loading…
Cancel
Save