0

I have a batch process(Spring batch), I want to create separate log file per batch execution, so that it will be easy for us to debug the entire flow using this single log file. Is there a way to achieve it. We are using log4j for logging across .

Shivaprasad
  • 167
  • 1
  • 9
  • We were able to achieve it adding FileAppender to the root Logger during runtime. Below is one sample code, which creates unique log file per execution. – Shivaprasad Sep 05 '14 at 12:04

1 Answers1

1

I think you can store dynamic log file name as a job parameter or into execution context and set log4j filename programmatically like described here using a JobExecutionListener.
I don't know how achive the same goal using log4j XML config and log4j properties substitution because I have never used log4j too much.

Community
  • 1
  • 1
Luca Basso Ricci
  • 17,829
  • 2
  • 47
  • 69
  • 2
    I was able to achieve it by dynamically configuring FileAppender at the run time. In the beginning of the job we will add the FileAppender to the root logger with an unique name and will remove it after the job execution. – Shivaprasad Sep 05 '14 at 12:01