JUnit5 mixed logs with parallel execution

2019-06-04 20:33发布

问题:

I'm migrating to JUnit5 (5.3.0-M1) and Log4j2 (2.11.0) and I'd like to know if there is an easy way in to handle the logs from different threads. In my previous version I could solve it with a CustomFileAppender, but now I think there might exist some better solution... the idea is to move from something like this:

[date] INFO - test1 - Doing something...
[date] INFO - test2 - Doing something...
[date] INFO - test1 - Doing something...
[date] INFO - test3 - Doing something...
[date] INFO - test1 - Doing something...
[date] INFO - test3 - Doing something...
[date] INFO - test2 - Doing something...

to something like this:

[date] INFO - test1 - Doing something...
[date] INFO - test1 - Doing something...
[date] INFO - test1 - Doing something...
[date] INFO - test2 - Doing something...
[date] INFO - test2 - Doing something...
[date] INFO - test3 - Doing something...
[date] INFO - test3 - Doing something...

Thanks in advance!