Search code examples
javalogginglog4japache-commons-logging

Create a new log file every time my program is run


I am using the Apache commons logging library and log4j to generate my log files.

Now I want to create a new file every time I run my program. The current count should be appended to the log file's name.

For example: program_1.log program_2.log program_3.log

Do you know how I could achieve this?


Solution

  • Turning my comment into an answer, as requested:

    Any reason why you don't want to use a timestamp? I've found them to be more meaningful as suffixes when I have to look back at log files.