diff --git a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java index 91bf92520..b76dd3341 100644 --- a/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java +++ b/spring-batch-core/src/main/java/org/springframework/batch/core/step/AbstractStep.java @@ -213,13 +213,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 { @@ -232,7 +232,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 { @@ -242,8 +242,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()); @@ -256,15 +256,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); }