Pass slf4j context to spawned thread by scottrw93 · Pull Request #3241 · apache/maven-surefire (original) (raw)
Now you have moved to slf4j it would be nice to pass the slf4j mdc context from the parent thread to the threads created by ThreadedStreamConsumer. The context is really useful for custom logging implementations in maven as when running in parallel mode it lets you do things like prefix the log line with the module name that generated it or grouping all logs by the module and printing them sequentially at the end of the build.
The best example of this is in mvnd where they prefix each log line with the module, but it doesn't work for surefire as the logging context is logged in the new thread. If multiple modules are running test at once its not clear which one generated the log line.
[maven-artifact] [INFO]
[maven-artifact] [INFO] -------------------------------------------------------
[maven-artifact] [INFO] T E S T S
[maven-artifact] [INFO] -------------------------------------------------------
[maven-slf4j-provider] [INFO] Enabled default license matchers.
[maven-slf4j-provider] [INFO] Will parse SCM ignores for exclusions...
[maven-slf4j-provider] [INFO] Finished adding exclusions from SCM ignore files.
[maven-slf4j-provider] [INFO] 62 implicit excludes (use -debug for more details).
[maven-slf4j-provider] [INFO] 18 explicit excludes (use -debug for more details).
[maven-slf4j-provider] [INFO] 7 resources included (use -debug for more details)
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 s - in org.apache.maven.model.CiManagementTest
[INFO] Running org.apache.maven.model.ReportingTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.035 s - in org.apache.maven.model.ReportingTest
[INFO] Running org.apache.maven.model.ScmTest
Following this checklist to help us incorporate your
contribution quickly and easily:
If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.