[JAVA-2953] Remove support for logging to JUL (java.util.logging) Created: 30/Aug/18 Updated: 28/Oct/23 Resolved: 03/Sep/19 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Monitoring |
| Affects Version/s: | 3.8.1 |
| Fix Version/s: | 4.0.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Dallas Phillips [X] | Assignee: | Jeffrey Yemin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
OSGI DS, ch.qos.logback.classic fragment implementation, Eclipse IDE, Java 1.8.0_181, Java Driver 3.8 |
||
| Backwards Compatibility: | Minor Change |
| Description |
| Comments |
| Comment by Githook User [ 15/Jan/20 ] |
|
Author: {'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}Message: Update logging reference documentation
|
| Comment by Githook User [ 15/Jan/20 ] |
|
Author: {'name': 'Jeff Yemin', 'username': 'jyemin', 'email': 'jeff.yemin@10gen.com'}Message: Remove JUL logging support The Java driver has supported logging with JUL (java.util.logging) since
|
| Comment by Dallas Phillips [X] [ 03/Sep/19 ] |
|
Awesome Jeffrey, thank you! |
| Comment by Jeffrey Yemin [ 03/Sep/19 ] |
|
I updated the description with the decision we arrived at. |
| Comment by bhanukiran karanam [ 03/Sep/19 ] |
|
Hi, May I know what is the fix. Thanks and Regards, |
| Comment by Jeffrey Yemin [ 31/Oct/18 ] |
|
We don't plan to branch for the 4.0 release until next summer, so a PR for this may be premature. We have also not decided yet whether to support JUL at all, so the work may turn out much simpler than you propose. Does your application require JUL, or are you more interested in disabling it? |
| Comment by bhanukiran karanam [ 31/Oct/18 ] |
|
Hi I would like to contribute to this feature as below.
Please let me know .. if I am correct in understanding the requirement and can create a PR with this change. |
| Comment by Jeffrey Yemin [ 04/Sep/18 ] |
|
Options to consider for the next major release of the driver:
|
| Comment by Jeffrey Yemin [ 31/Aug/18 ] |
|
Sounds good. I changed the status to Open. Thanks for helping with the investigation. |
| Comment by Dallas Phillips [X] [ 30/Aug/18 ] |
|
I was able to edit the Java JRE's logging.properties file and '.level' to OFF. This did solve what I was trying to accomplish. After, I put back the original properties and tried to do this using the LogManager but the bundle that has the driver has to be activated before the bundle depending on it can so the logging occurs before the manager can do anything about it. So back to JRE global to OFF. Disabling the fallback would be nice so that the JRE properties don't have to be muddled with if the logging is not desired. If someone wanted the logging, they should include SLF4J into their project to allow the driver to do so. If having the fallback is legacy then I would ask this be made into a request. |
| Comment by Jeffrey Yemin [ 30/Aug/18 ] |
|
Currently the only way to disable logging completely is via the logging system, which will either be an SLF4J-compatible library like Logback or Log4J, or otherwise JUL. For the latter, the Javadoc for java.util.logging.Logger and/or java.util.logging.LogManager describes how to accomplish this for JUL. Assuming this doesn't meet your needs, we can treat this as a request for a driver API to completely disable logging, or perhaps to disable the JUL fallback, which is really a legacy of the driver going back to its inception. |
| Comment by Dallas Phillips [X] [ 30/Aug/18 ] |
|
This may be a my-misunderstanding moment. With that said though, the driver is not detecting SLF4J but is using JUL. Is there no way to prevent any logging from the driver? Maybe the scope of the question should just be reduced to that rather than the specifics of which logger it's deciding to use. |
| Comment by Jeffrey Yemin [ 30/Aug/18 ] |
|
I suspect that if the driver is using JULLogger then it's not detecting SLF4J at all, and wouldn't use SLF4J no matter what the logging level. Based on the code I shared, that would mean the driver is not able to load the org.slf4j.Logger class from its default class loader. Can you confirm whether the driver logs through SLF4J in any circumstance? It doesn't make sense that it would change from SLF4J to JUL solely based on a change to the Logback configuration of logging levels. |
| Comment by Dallas Phillips [X] [ 30/Aug/18 ] |
|
It was frustrating to see that everything I did, which seemed hackish, wouldn't stop logging. Maybe it is a lack of documentation on how to control it, but there is no way to then that is what I am suggesting. It may be helpful to know that the logging was coming from com.mongodb.diagnostics.logging. |
| Comment by Jeffrey Yemin [ 30/Aug/18 ] |
|
I'm surprised by this behavior. Looking at this code the driver will use SLF4J so long as it can load the org.slf4j.Logger class. It doesn't check logging levels. |