I would like that each JUnit 5 test has its own log4j2 log file. This log file I would then like to attach to the Allure HTML test report.
Yesterday I tried two different approaches which I had googled, but it did not work. One was to use system properties in the log4j2 configuration file. But these are obviously initialized only once. Now that I write these lines, I wonder if there is a way to trigger reinitialization of the log configuration at runtime?
Then I tried a method where I programatically update the appenders. It was horribly complicated, deep inside internals of log4j2. And it did not work, some stream was already closed it said at the end, and then I gave up.
Before I try again, what would be a smart and safe way to do it?