Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
apjanke opened this issue Sep 12, 2022 · 2 comments
Open

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

apjanke opened this issue Sep 12, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@apjanke
Copy link
Member

apjanke commented Sep 12, 2022

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 apjanke self-assigned this Sep 12, 2022
@apjanke apjanke added the enhancement New feature or request label Sep 12, 2022
@apjanke apjanke added this to the SLF4M 2.0.0 milestone Sep 12, 2022
@apjanke apjanke changed the title Make junit tests quiet in normal build targets in log4j Make junit tests quiet in normal build targets in log4j 1.2 Sep 15, 2022
@apjanke
Copy link
Member Author

apjanke commented Sep 15, 2022

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
Copy link
Member Author

apjanke commented Sep 15, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant