I am using eclipse with testng and I am using log4j2 for the logging. When I run the tests separately, a log file is created for each test and placed in a directory that has a unique name including the datetime stamp.
For example, when I run test01, a directory is created with the datetime and a log file is placed in that directory.
2016-12-10-21-16-04 tst_01
tst_01.log
When I run test02 separately, a new directory is created based on the datetime and testname and a log file is added to the new directory.
2016-12-10-21-16-42 tst_02
tst_02.log
When I run the test suite using testng. One log file is added to the directory of the first test, but there is no log file that appears in the second directory.
Also the log file that ends up in the directory of the first test contains the log statements for the first test as well as the second test.
Code Example:
public class TestLog{
private static final Logger TestLog = LogManager.getLogger(TestLog.class.getName());
public static void info(String message){
TestLog.info(message);
}
}
Question: How do I get a new log file to be created when running the tests using testng?