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
Added information about capturing static inner classes, fixed javadoc warnings #14
Conversation
Hi Vasiliy, Nice catch and thank you for providing a PR with a fix for it. I like the implementation and the usage of the Optional. I really appreciate that you fixed the build warnings regarding the javadoc, but what do you think of the resulting javadoc for those two methods? |
It works fine with Log4j2 and Slf4j, but there are problems with JUL: Lombok Javadoc looks fine for me both in Idea and browser. Should I add something else? |
Well I was considering to suppress the warning by adjusting the javadoc plugin instead of adding the return type within the documentation. But I think what you did is better as my approach would also suppress other issues if they would occur in the future. So lets keep your changes 😊
Aha, good that we have discovered this for JUL. I still like the feature of capturing the inner classes and having this support for SLF4J and Log4J2 based logging api/implementations. So I would suggest to have a new section within Known issues maybe called And maybe it is also good to have a unit test for slf4j with inner class which passes. And one unit test for jul with inner classes which does not return logs. In that way we have covered the three use cases within the tests if thats not too much effort for you. What do you think, would it be valuable to add that? |
3af26e5
to
2cc594c
Compare
I think I was sleepy at time when I was testing it but situation is opposite) |
Hmm, The code changes looks good to me and I want to try this locally so I am just merging this PR. I want to test with couple of different scenarios to discover the behaviour with different use cases. Thank you for this discovery and improvements on the library! |
@all-contributors please add @AkaZver for design ideas research |
I've put up a pull request to add @AkaZver! 🎉 |
I have refactored your PR, hope you won't be mad as I changed most of the stuff. The unit test you have provided are very compact and advanced which I liked at the time of merging it, but I preferred to move them to separate classes and packages. The resulting code is unfortunately verbose but easier to maintain for me. I also discovered that static inner classes works with Log4J. Strange that Apache decided to change the behaviour for Log4J2. But I like the documentation you added, it clearly states how you should properly test those cases 👍🏼 |
Hello!
Originally I've found this issue in Spring Boot integration tests
How to reproduce: create some static inner class and try to capture its logs - it will write logs as expected but nothing will be captured
It happens because
Class.getName()
on static inner class will return something like org.example.untitled.Main$Inner but for correct capturing we need org.example.untitled.Main.Inner which can be returned byClass.getCanonicalName()
(also may return null in some cases so I usedOptional
)Also fixed some javadoc warnings from build log
Please review and give me some feedback)
Thx