1

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!

jmrg82
  • 111
  • 1
  • 7
  • Are you using a logging framework? These usually provide support to output the thread ID as well. – Marc Philipp Jul 23 '18 at 10:43
  • Are you asking how to create a separate log for each thread using log4j2? – D.B. Jul 23 '18 at 22:49
  • Not exactly, I'm using a custom framework, so I have to implement my own solution. And the idea is not to create different files per each thread, but to have one single file with the information of them, appended entirely when each thread finishes. – jmrg82 Jul 24 '18 at 10:14

0 Answers0