I have a Java application that uses the log4j logging framework. In my application I have several modules and each module creates its own log file. I start my application via command line, passing a parameter to tell my application which module it should be run. Lets say I have 3 modules so everytime one module gets started, all 3 log files are being created but just one is filled with information (the one from the module I just started). I have set each File Appender to
...append = false
so that everytime I start my application I have fresh log files without old log data.
Now I have a batch file which creates a process chain, so all 3 modules are called right after the other within the batch file. But the problem is: At the end the log files from the first 2 modules are empty and only the last module stored its logs in the correct log file (of course this has to be like that because I set the append option to fasle for each file appender)
I am looking for the following solution: When I start a module I want to check if the log file for this module is empty. If yes then I just append the logging data to this file. If there is already data in the file I want to delete the content to store the current logging data. So at the end when I call all 3 modules (starting the application 3 times with different parameters each time) I want to have all 3 log files filled. Any ideas?