[
https://jira.jboss.org/jira/browse/JGRP-851?page=com.atlassian.jira.plugi...
]
Richard Achmatowicz commented on JGRP-851:
------------------------------------------
I've had a look at this and built an implementation which works, or seems to work.
Log4j uses a ConsoleAppender to write logging statements to the console. Looking at the
implementation of the ConsoleAppender, there are two relevant points:
(i) the console appender writes to System.out and System.err using the methods flush(),
write(byte[] b), write(byte[] b, int off, int len) and write(int b)
(ii) the ConsoleAppender has an instance variable follow, which if true will allow the
ConsoleAppender to write to System.out and System.err even if they are redirected after
the initialization of the ConsoleAppender.
JUnitXMLReporter plays a trick with System.out and System.err, overriding the default
implementation with an implementation of a PrintStream which takes print() and println()
commands sent to System.out and System.err and writing them to a test class specific
buffer which is then used to generate test reports.
The solution to integrating the logging output with the test case output is therefore
to:
(i) add implementations of the methods flush(), write(byte[] b), write(byte[] b, int off,
int len) and write(int b) to JUnitXMLReporter.MyOutput which is the replacement
PrintStream
(ii) in the log4j.properties file, include the following extra option
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.Follow=true
This cases output to flow from the logging statements in the test case, through the
console appender, through the substituted System.out and System.err and into the test case
XML files.
Integrate commons-logging output with testNG test case reports
--------------------------------------------------------------
Key: JGRP-851
URL:
https://jira.jboss.org/jira/browse/JGRP-851
Project: JGroups
Issue Type: Bug
Reporter: Richard Achmatowicz
Assignee: Richard Achmatowicz
Priority: Minor
Fix For: 2.7
At present, logging output from commons-logging gets directed by the ConsoleAppender to
the console. This is unfortunate for two reasons: (i) as the output from a testNG test
case (collected by org.jgroups.util.JUnitXMLReporter) and the logging output are now not
collected together and (ii) the logging output is effectively lost when the console dies.
Need to find a way to cause the commons-logging output (which is supported by a log4j
implementation) to be collected together with the test cases.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira