S
S
Sergey Tryapkin2018-10-12 15:00:45
Java
Sergey Tryapkin, 2018-10-12 15:00:45

Test execution logging, in a separate file?

Good afternoon.
I just can't figure out how to configure log4j2 to output the log to a separate file for each test class.
There is log4j2, Google did not give any results.
The tests are run in parallel.
Requires that the execution of each test class be written to a separate file.
I will be glad for any hint.
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Eremin, 2018-10-12
@Triapkin

well, I would do this option:
https://stackoverflow.com/questions/8965946/config...

FileAppender fa = new FileAppender();
  fa.setName("FileLogger");
  fa.setFile("mylog.log");
  fa.setLayout(new PatternLayout("%d %-5p [%c{1}] %m%n"));
  fa.setThreshold(Level.DEBUG);
  fa.setAppend(true);
  fa.activateOptions();

  //add appender to any Logger (here is root)
  private final Logger logger = Logger.getRootLogger().addAppender(fa);

in each class we create our own file and log into it
only, where fa.setFile("mylog.log"), either generate a UDID there, or use the stream id and stick it in the file name
UPD: the name of the logger, probably, is also better to generate

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question