janklab / slf4m-jankalog

Modified forks of FLOSS logging libraries to support SLF4M
Other
0 stars 0 forks source link

Make junit tests quiet in normal build targets in log4j 1.2 #11

Open apjanke opened 2 years ago

apjanke commented 2 years ago

The site and assembly targets in log4j output hundreds of lines of detailed JUnit test progress and results.

    [...]
    [junit] Testcase: testBadTabbing took 0 sec
    [junit] Testcase: testHeaderLogging took 0.003 sec
    [junit] Testcase: testLayoutHeader took 0.003 sec
    [junit] Testcase: testBigPackets took 0 sec
    [junit] Testcase: testTwoParamConstructor took 0 sec
    [junit] Testcase: testTwoParamConstructorBadFacility took 0 sec
    [junit] Testcase: testThreeParamConstructor took 0.002 sec
    [junit] Testcase: testGetFacilityString took 0 sec
    [junit] Testcase: testGetFacilityStringUnexpected took 0 sec
    [junit] Testcase: testGetFacilityBogus took 0 sec
    [...]

Seems especially gross that, it looks like, unit tests that check that log4j throws exceptions in certain cases output those expected-exception stack traces.

    [...]
    [junit] log4j: Setting property [reconnectionDelay] to [0].
    [junit] log4j: FB: The following error reported: Could not connect to remote log4j server at [localhost]. We are not retrying.
    [junit] java.net.ConnectException: Connection refused (Connection refused)
    [junit]     at java.net.PlainSocketImpl.socketConnect(Native Method)
    [junit]     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    [junit]     at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    [junit]     at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    [junit]     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    [junit]     at java.net.Socket.connect(Socket.java:607)
    [junit]     at java.net.Socket.connect(Socket.java:556)
    [junit]     at java.net.Socket.<init>(Socket.java:452)
    [junit]     at java.net.Socket.<init>(Socket.java:262)
    [junit]     at org.apache.log4j.net.SocketAppender.connect(SocketAppender.java:204)
    [junit]     at org.apache.log4j.net.SocketAppender.activateOptions(SocketAppender.java:161)
    [junit]     at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:257)
    [junit]     at org.apache.log4j.xml.DOMConfigurator.parseAppender(DOMConfigurator.java:285)
    [...]

I'd rather not see that unless I explicitly ask for it. See if there's a way to turn all that off. Only output failures and errors by default.

apjanke commented 2 years ago

Oh, you know what? Looks like this output was not from the Maven surefire plugin, but from the antrun plugin running the ant JUnit test. So it's not under the direct control of the pom.xml; it's controlled by build.xml; that's probably why my attempts to quiet surefire didn't work. I turned off the antrun junit tests in #21, and all this output disappeared. :)

apjanke commented 2 years ago

And, haha, guess what? In pom.xml's <build><plugins><plugin><configuration> for maven-surefire-plugin, there's a <skip>true</skip>, which means surefire isn't running any tests at all. I removed that <skip>true</skip>, and surefire went to running tests, and there were several failures. I guess that's why log4j is calling out to ant for its unit testing? I put the <skip>true</skip> back in, because I just want to get it building first.