-
Notifications
You must be signed in to change notification settings - Fork 695
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
fix: Verbose logging introduced by LogCaptor #1849
Conversation
Adding the LogCaptor dependency caused the logging level to be DEBUG instead of INFO, even though it is configured to be INFO in log4j2.xml. This is a known issue (Hakky54/log-captor#8) because LogCaptor uses a different appender than the one configured in log4j2.xml. More details in this comment: Hakky54/log-captor#8 (comment). The solution is to remove the dependency and create a custom appender which is used to test the logs.
Add TestAppender programmatically for one test rather than enable it for all tests.
@joc-a there is a solution for the issue you are facing. You can have logcaptor and mute all of the logs in the console or build output and still do the assertions. I use the following test resource which you can copy over https://github.com/Hakky54/sslcontext-kickstart/blob/master/sslcontext-kickstart/src/test/resources/logback-test.xml I was waiting for your input on the issue you created here Hakky54/log-captor#47 Do you think it is worth to give it a shot with the logback-test.xml file? |
Hey @Hakky54. Thank you for your suggestion. I did try that solution at first after searching through the issues on GitHub, but it won't work for this case because it would completely mute all logs, including those that we would expect to see if there is something being logged that should not be there. I wanted the logging behaviour to be exactly the same as before introducing LogCaptor, meaning that if a bug is reintroduced that causes unwanted logging, we should be able to catch it both by the assertion in the test and by seeing the it in the console. |
I think it should be possible, if you are ok I would like to give it a shot. Can you point out which logs you still want to see and which should not appear? |
@Hakky54 If you change this line here to this
This should be the only warning with nothing else. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check #1852, it looks much simpler
Closing this in favour of #1852 |
Adding the LogCaptor dependency caused the logging level to be DEBUG instead of INFO, even though it is configured to be INFO in
log4j2.xml
. This is a known issue (Hakky54/log-captor#8) because LogCaptor uses a different appender than the one configured inlog4j2.xml
. More details in this comment: Hakky54/log-captor#8 (comment).The solution is to remove the dependency and create a custom appender which is used to test the logs.
Partially inspired by this.