Dynamic file name in log4j’s file appender
In your log4j.xml, set the file name as a variable <appender name=”my-file-appender” class=”org.apache.log4j.FileAppender”> <param name=”file” value=”${myFilePath}” /> <!– … –> </appender> Then in your java code, make sure the following is called before the first getLogger() call System.setProperty(“myFilePath”, someFilePath);