-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Introduce custom logging façade on top of JUL #834
Comments
I am currently not in favor of introducing a custom logging façade. I think JUL should continue to suffice for our needs. |
Having said that, I am in favor of introducing more logging and/or proper error handling. |
Error handling will be addressed in #242. |
Providing additional context in error messages will be addressed in #602. |
FYI: added Related Issues section to issue description. |
Currently slated for 5.0 M5 in order to discuss this topic in a timely manner. |
@sormuras: Could you describe the rationale for creating a facade (excuse me if I forego the fancy "c" 😉)? What would the different backends be? |
A true façade was not intended, we should stick with JUL as our framework of choice. Maybe an internal |
@sormuras I find this intriguing. With a slim facade like the one you propose (please don't call it In Java 9 in particular, there's redirected platform logging, which allows logging backends to be plugged into the JDK to route messages through them. This would allow JUnit 5 to use a JDK API while still allowing clients to receive the messages through whatever logging framework they prefer. So if someone has a use case for getting JUnit's messages through Logback, that would be possible on Java 9 without JUnit adopting any new dependencies. While nice in theory, it raises the question why anybody would want to do that. I have to admit, I never had that use case. |
Just a note since this thread started with Spring 5: That step came out of a special situation with 13 years of history, so our choice of implementing a custom Commons Logging variant happens to be our smoothest way out of this: preserving binary compatibility while having first-class support for Log4J 2, SLF4J and JUL... by default, without custom Maven setup. I wouldn't recommend this to anyone else unless there is also a lot of existing third-party code with Commons Logging references for a particular framework out there... So for JUnit 5 in particular, I'd also stick with JUL. Test environments are more controlled to begin with, and the most relevant part are assertions which bubble up to the execution environment. Any intermediate logging is really more of a bonus, trying to analyze JUnit extension interferences, that sort of stuff? In any case, server applications are certainly different since even hard failures need to be analyzed through the log, not just passing back an error response to the client but also tracking such occurrences on the server. |
Hi @jhoeller! Thanks for sharing your insight with regard to Spring's special needs. We'll definitely take those points into consideration. If we end up creating any kind of logging facade for JUnit, I think it would simply be a wrapper around JUL that provides us a better API than the one in JUL itself. In other words, I don't foresee us aiming for interoperability with multiple logging frameworks. Cheers, Sam |
@sormuras, looks like we're on the same page. 😉 |
I wonder what the output looks like if we don't use Log4j. And also how they know about the facade? Fancy. Still like the solution because of its simple and clean interface. Thanks. Second time of a comment race condition. ;-) so we should add Spring's code for the Thanks for testing and providing the poc 👍 |
Well, I'm not sure I'm a fan of turning off logging by default, but.... it would certainly be possible with such a façade. The check would go in |
@sbrannen, of course I'm happy for the Spring 5 logging code to be used (directly or as an inspiration) in JUnit 5. There is prior art here in the logging bridges (e.g. SLF4J-JUL) anyway, so it's a quite common approach at this point. |
Awesome, @jhoeller. Thanks so much! 👍 |
This is a "work in progress". Issue: #834
This is a "work in progress". Issue: #834
Update I just added support for populating the source class name and method name based on the current call stack. junit5/junit-platform-commons/src/main/java/org/junit/platform/commons/logging/LoggerFactory.java Lines 108 to 134 in b6a998c
|
With the above change in place, the following is the new (correct) log output from the corresponding test when using JUL directly (i.e., JUL as the implementation of the JUL API).
The log statement now correctly comes from |
Great! 👍 |
@junit-team/junit-lambda I am in favor of using our own custom logging façade for JUL effective immediately. Rationale: using our façade would avoid the need for "fix up" commits like my last two: Since the usage of the façade would only be internal, I don't foresee any negative side effects for end users. Thoughts? |
Update Tentatively slated for 5.0 GA in order to discuss usage of the façade immediately, with further refinements potentially coming in 5.0.x or 5.1. |
Updated Deliverables. I propose that the task "Make custom logging façade testable" could potentially be pushed back until 5.0.x or 5.1. |
I could live with having it in 5.0. So +1 |
This commit introduces a custom logging façade for Java Util Logging (JUL) to be used internally within the framework. Issue: #834
This commit introduces a custom logging façade for Java Util Logging (JUL) to be used internally within the framework. Issue: junit-team#834
Overview
We are considering to write and use our own custom façade. Something like was done in Spring.
Add more logging statements to the code, especially when it comes to configuration/setup with engines, listeners, test class/method invocations.
Related Issues
Deliverables
The text was updated successfully, but these errors were encountered: