[GRADLE-2841] Logging from tools like log4j is not captured by TestNG execution Created: 16/Jul/13 Updated: 29/Jan/15 Resolved: 07/Nov/14 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | 2.3-rc-1 |
Type: | Bug | ||
Reporter: | Gradle Forums | Assignee: | Szczepan Faber |
Resolution: | Fixed | Votes: | 0 |
Description |
Logging from tools like log4j/slf4j is not captured by TestNG execution Problem: If someone uses standard logging tool like log4j the messages are not captured by Gradle, hence they don't appear in the test results (html/xml) and they are not passed onto the listeners. (btw. it works just fine for JUnit) Symptoms:
Investigation: For TestNG, we load all the test classes before triggering execution. If the class has a static Logger field (standard style of using a loggin toolkit), the static state gets initialized during class loading (TestNGTestClassProcessor.processTestClass), at this point the log4j initializes loggers and hooks up to the system output / error. Later, the test classes get executed (TestNGTestClassProcessor.stop) and the standard output/error redirector is started (CaptureTestOutputTestResultProcessor.started). However, now it's too late - log4j has already initialized and pushes the output directly to build log. Possible solutions:
|
Comments |
Comment by Gradle Forums [ 16/Jul/13 ] |
Just tried out your sample, thanks. It's log4j that is the problem. It's eagerly grabbing a reference to System.err so it bypasses our mechanism for capturing what is output. I'll raise a separate issue for this. |
Comment by Gradle Forums [ 16/Jul/13 ] |
Sorry, slf4j. |
Comment by Gradle Forums [ 16/Jul/13 ] |
Thanks for your response Luke, please paste bug reference here once it's created so I can watch it. |
Comment by Sebastian Glahn [ 29/Jan/15 ] |
The release notes of 2.3-rc-1 are marking this bug as solved but it looks like that is not true.
Can you provide a link to this issue please? |