BATCH-2083: Improved logging detail in AbstractStep

This commit is contained in:
Michael Minella
2014-03-11 11:21:30 -05:00
parent 7ca75f58bc
commit aa9a0fdcb2

View File

@@ -216,13 +216,13 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
exitStatus = exitStatus.and(getDefaultExitStatusForFailure(e));
stepExecution.addFailureException(e);
if (stepExecution.getStatus() == BatchStatus.STOPPED) {
logger.info("Encountered interruption executing step: " + e.getMessage());
logger.info(String.format("Encountered interruption executing step %s in job %s : %s", name, stepExecution.getJobExecution().getJobInstance().getJobName(), e.getMessage()));
if (logger.isDebugEnabled()) {
logger.debug("Full exception", e);
}
}
else {
logger.error("Encountered an error executing the step", e);
logger.error(String.format("Encountered an error executing step %s in job %s", name, stepExecution.getJobExecution().getJobInstance().getJobName()), e);
}
}
finally {
@@ -235,7 +235,7 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
exitStatus = exitStatus.and(getCompositeListener().afterStep(stepExecution));
}
catch (Exception e) {
logger.error("Exception in afterStep callback", e);
logger.error(String.format("Exception in afterStep callback in step %s in job %s", name, stepExecution.getJobExecution().getJobInstance().getJobName()), e);
}
try {
@@ -245,8 +245,8 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
stepExecution.setStatus(BatchStatus.UNKNOWN);
exitStatus = exitStatus.and(ExitStatus.UNKNOWN);
stepExecution.addFailureException(e);
logger.error("Encountered an error saving batch meta data. "
+ "This job is now in an unknown state and should not be restarted.", e);
logger.error(String.format("Encountered an error saving batch meta data for step %s in job %s. "
+ "This job is now in an unknown state and should not be restarted.", name, stepExecution.getJobExecution().getJobInstance().getJobName()), e);
}
stepExecution.setEndTime(new Date());
@@ -259,15 +259,15 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw
stepExecution.setStatus(BatchStatus.UNKNOWN);
stepExecution.setExitStatus(exitStatus.and(ExitStatus.UNKNOWN));
stepExecution.addFailureException(e);
logger.error("Encountered an error saving batch meta data. "
+ "This job is now in an unknown state and should not be restarted.", e);
logger.error(String.format("Encountered an error saving batch meta data for step %s in job %s. "
+ "This job is now in an unknown state and should not be restarted.", name, stepExecution.getJobExecution().getJobInstance().getJobName()), e);
}
try {
close(stepExecution.getExecutionContext());
}
catch (Exception e) {
logger.error("Exception while closing step execution resources", e);
logger.error(String.format("Exception while closing step execution resources in step %s in job %s", name, stepExecution.getJobExecution().getJobInstance().getJobName()), e);
stepExecution.addFailureException(e);
}