public class LoggingListener extends Object implements org.springframework.batch.core.JobExecutionListener, org.springframework.batch.core.StepExecutionListener, org.springframework.core.Ordered
JobExecutionListener and a StepExecutionListener
because in partitioning we may have a lot of StepExecutions running in different threads.
Due to the fact that the afterStep - method would remove the variable from the MDC in single threaded
execution we need to re-set it, that's what's the LoggingAfterJobListener is for.
Note that, of the three local parallelization features in Spring Batch, log file separation only
works for partitioning and parallel step, not for multi-threaded step.
The log file name is determined by a JobLogFileNameCreator. It's default implementation
DefaultJobLogFileNameCreator is used when there's no other bean of this type in the
ApplicationContext.| Modifier and Type | Field and Description |
|---|---|
static String |
JOBLOG_FILENAME |
| Constructor and Description |
|---|
LoggingListener() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterJob(org.springframework.batch.core.JobExecution jobExecution) |
org.springframework.batch.core.ExitStatus |
afterStep(org.springframework.batch.core.StepExecution stepExecution) |
void |
beforeJob(org.springframework.batch.core.JobExecution jobExecution) |
void |
beforeStep(org.springframework.batch.core.StepExecution stepExecution) |
int |
getOrder() |
void |
setJobLogFileNameCreator(JobLogFileNameCreator jobLogFileNameCreator) |
public static final String JOBLOG_FILENAME
public void beforeJob(org.springframework.batch.core.JobExecution jobExecution)
beforeJob in interface org.springframework.batch.core.JobExecutionListenerpublic void afterJob(org.springframework.batch.core.JobExecution jobExecution)
afterJob in interface org.springframework.batch.core.JobExecutionListenerpublic void beforeStep(org.springframework.batch.core.StepExecution stepExecution)
beforeStep in interface org.springframework.batch.core.StepExecutionListenerpublic org.springframework.batch.core.ExitStatus afterStep(org.springframework.batch.core.StepExecution stepExecution)
afterStep in interface org.springframework.batch.core.StepExecutionListenerpublic int getOrder()
getOrder in interface org.springframework.core.Ordered@Autowired(required=false) public void setJobLogFileNameCreator(JobLogFileNameCreator jobLogFileNameCreator)
Copyright © 2016. All Rights Reserved.