From 4d3090ac023d1ebc9e95ef735378647b7db74f7e Mon Sep 17 00:00:00 2001 From: Mahmoud Ben Hassine Date: Thu, 16 May 2019 14:54:19 +0200 Subject: [PATCH] Show step execution duration in the logs Resolves BATCH-2823 --- .../java/org/springframework/batch/core/step/AbstractStep.java | 3 +++ 1 file changed, 3 insertions(+) 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 8dc61a88a..08dd2f993 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 @@ -15,6 +15,7 @@ */ package org.springframework.batch.core.step; +import java.time.Duration; import java.util.Date; import io.micrometer.core.instrument.Tag; @@ -267,6 +268,8 @@ public abstract class AbstractStep implements Step, InitializingBean, BeanNameAw )); stepExecution.setEndTime(new Date()); stepExecution.setExitStatus(exitStatus); + Duration stepExecutionDuration = BatchMetrics.calculateDuration(stepExecution.getStartTime(), stepExecution.getEndTime()); + logger.info("Step: [" + stepExecution.getStepName() + "] executed in " + BatchMetrics.formatDuration(stepExecutionDuration)); try { getJobRepository().update(stepExecution);