Igor Fedorenko <i...@ifedorenko.com> wrote on 05/25/2015 07:28:45 AM:

> I had to troubleshoot a large multithreaded build last week and that
> proved to be rather difficult mostly because build log was a jumble of
> messages produced by concurrently running threads. It was not possible
> to tell which message came from which thread, which made the build log
> more or less useless.
> 
> What I ended up doing was to write per-module log message to individual
> ${project.build.directory}/build.log log files.
> 
> That was kinda tricky to implement because log files were opened very
> early during module build and were subsequently deleted by
> maven-clean-plugin (I tried on Linux and OSX, and I assume the build
> will fail on Windows). I had to modify maven-clean-plugin configuration
> in the project pom.xml to retain ${project.build.directory}/build.log
> files.
> 
> I felt my solution required too my effort and I wonder what others do to
> capture logs during multithreaded builds. Can we come up with a
> "recommended" way of doing this?

In my Ant days we had a similar problem. I ended up writing a thread-aware 
logging implementation that would buffer log messages in memory, then 
flush meaningful sections when a logging context ended. The logs ended up 
being out-of-order when viewed strictly as a time sequence, but the 
sections did make sense and allowed someone to follow in a coherent manner 
what happened in a particular context during the build.

I tried to do something similar when I changed teams and we were using 
Maven, but frankly the Ant API for plugging in loggers & listeners was 
easier to work with. I'm currently working on thread-aware event spies for 
performance profiling & would be happy to work on a thread aware logger as 
well if there is interest.

Reply via email to