javalog4jfileappender

Log4j file appender for each instance of a class


I have a scenario class, which has list of Test cases. Is there any way that I can save each Test case execution to separate file with name: TestCaseName.log?

I have done this before with java.util.logging by adding file handler in the code, but have no idea how to do this with Log4j.


Solution

  • Task was completed by adding RollingFileAppenders programmatically, just like in this example: http://howtodoinjava.com/2013/04/08/how-to-programmatically-configure-appenders-in-log4j/