Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1123

Use SLF4J instead of Java Util Logging for higher flexibility

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.0.0
    • Affects Version/s: 2.11.4
    • Component/s: None
    • Labels:
    • Environment:

      Currently Mongo Java Driver uses JUL for logging. This causes a few troubles for developers that are using other logger implementations in their apps, specifically because JUL is part of core JDK and is hard to override. Also having multiple different loggers is just causing a structural mess.

      If a bridge API, such as SLF4J is used instead, it's possible to allow developers to use any type of logger provider, be it JUL, Log4J, JCL, Logback..

      The only thing that Java Driver needs is use SLF4J-API to create logger, the specific API implementation that developer chooses for their apps is going to do the rest of heavy lifting. SLF4J also provides bridges that override other log implementations, but due to the fact that JUL is core JDK - this operation is costy (very!).

      Another great thing with SLF4J is that it provides a much more optimised way of using the log statements - with placeholder support, placeholder value is only evaluated if and only if debug is enabled. Traditionally this is not the case and in apps requiring best performance, this can lead to performance improvement.

      As the design idea of mongo driver is not to have any 3rd party dependency, it could be possible to either include the tiny SLF4J API directly instead of the driver code or do something to check if SLF4J is present and use that instead.

      More Info about SLF4J: http://www.slf4j.org/
      How Legacy loggers could be supported: http://www.slf4j.org/legacy.html

            Unassigned Unassigned
            alexej.kubarev@accedo.tv Alexej Kubarev
            0 Vote for this issue
            2 Start watching this issue