Skip to content

DOCSP-51344: Logging #115

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

Open
wants to merge 9 commits into
base: comp-cov
Choose a base branch
from

Conversation

mcmorisi
Copy link
Collaborator

@mcmorisi mcmorisi commented Jul 11, 2025

Mostly adapted from the Java Sync Logging page, made efforts to trim the fat and update the wording.

Pull Request Info

PR Reviewing Guidelines

JIRA - https://jira.mongodb.org/browse/DOCSP-51344

Staging Links

  • logging-and-monitoring
  • logging-and-monitoring/logging
  • Self-Review Checklist

    • Is this free of any warnings or errors in the RST?
    • Did you run a spell-check?
    • Did you run a grammar-check?
    • Are all the links working?
    • Are the facets and meta keywords accurate?
    • Are the page titles greater than 20 characters long and SEO relevant?

    Copy link

    netlify bot commented Jul 11, 2025

    Deploy Preview for docs-kotlin-sync ready!

    Name Link
    🔨 Latest commit 7cdcde2
    🔍 Latest deploy log https://app.netlify.com/projects/docs-kotlin-sync/deploys/6881348c7821790008eb5e27
    😎 Deploy Preview https://deploy-preview-115--docs-kotlin-sync.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify project configuration.

    @docs-builder-bot
    Copy link

    docs-builder-bot commented Jul 11, 2025

    🔄 Deploy Preview for docs-kotlin-sync processing

    Item Details
    🔨 Latest Commit e56c7408b985527fca2062c9ed15a5738a7fd7ce
    😎 Deploy Preview https://deploy-preview-115--docs-kotlin-sync.netlify.app
    🔍 Build Logs View Logs

    Copy link
    Collaborator

    @mballard-mdb mballard-mdb left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Looks good! Left a few changes

    @mcmorisi mcmorisi requested a review from mballard-mdb July 11, 2025 18:15
    Copy link
    Collaborator

    @mballard-mdb mballard-mdb left a comment

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    LGTM with one follow up comment

    @mcmorisi mcmorisi marked this pull request as ready for review July 11, 2025 19:42
    @mcmorisi mcmorisi requested review from a team and vbabanin and removed request for a team July 11, 2025 19:43
    @mcmorisi mcmorisi requested a review from vbabanin July 22, 2025 20:31

    ...
    13:21:29.164 [main] INFO org.mongodb.driver.client - MongoClient with metadata {"driver": {"name": "mongo-java-driver|sync|kotlin", "version": "5.6.0-alpha0-20-g222541cd92-dirty"}, "os": {"type": "Darwin", "name": "Mac OS X", "architecture": "aarch64", "version": "15.5"}, "platform": "Java/JetBrains s.r.o./17.0.9+8-b1166.2|kotlin/1.8.10"} created with settings MongoClientSettings{readPreference=primary, writeConcern=WriteConcern{w=null, wTimeout=null ms, journal=null}, retryWrites=true, retryReads=true, readConcern=ReadConcern{level=null}, credential=null, transportSettings=null, commandListeners=[], codecRegistry=ProvidersCodecRegistry{codecProviders=[ValueCodecProvider{}, BsonValueCodecProvider{}, DBRefCodecProvider{}, DBObjectCodecProvider{}, DocumentCodecProvider{}, CollectionCodecProvider{}, IterableCodecProvider{}, MapCodecProvider{}, GeoJsonCodecProvider{}, GridFSFileCodecProvider{}, Jsr310CodecProvider{}, JsonObjectCodecProvider{}, BsonCodecProvider{}, EnumCodecProvider{}, com.mongodb.client.model.mql.ExpressionCodecProvider@63a12c68, com.mongodb.Jep395RecordCodecProvider@28f3b248, com.mongodb.KotlinCodecProvider@1b1426f4]}, loggerSettings=LoggerSettings{maxDocumentLength=1000}, clusterSettings={hosts=[localhost:27017], srvServiceName=mongodb, mode=SINGLE, requiredClusterType=UNKNOWN, requiredReplicaSetName='null', serverSelector='null', clusterListeners='[]', serverSelectionTimeout='30000 ms', localThreshold='15 ms'}, socketSettings=SocketSettings{connectTimeoutMS=10000, readTimeoutMS=0, receiveBufferSize=0, proxySettings=ProxySettings{host=null, port=null, username=null, password=null}}, heartbeatSocketSettings=SocketSettings{connectTimeoutMS=10000, readTimeoutMS=10000, receiveBufferSize=0, proxySettings=ProxySettings{host=null, port=null, username=null, password=null}}, connectionPoolSettings=ConnectionPoolSettings{maxSize=100, minSize=0, maxWaitTimeMS=120000, maxConnectionLifeTimeMS=0, maxConnectionIdleTimeMS=0, maintenanceInitialDelayMS=0, maintenanceFrequencyMS=60000, connectionPoolListeners=[], maxConnecting=2}, serverSettings=ServerSettings{heartbeatFrequencyMS=10000, minHeartbeatFrequencyMS=500, serverMonitoringMode=AUTO, serverListeners='[]', serverMonitorListeners='[]'}, sslSettings=SslSettings{enabled=false, invalidHostNameAllowed=false, context=null}, applicationName='null', compressorList=[], uuidRepresentation=UNSPECIFIED, serverApi=null, autoEncryptionSettings=null, dnsClient=null, inetAddressResolver=null, contextProvider=null, timeoutMS=null}
    Copy link
    Member

    @vbabanin vbabanin Jul 23, 2025

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    The logs provided here are mixed with DEBUG level, however, this section is about INFO level.

    Currently, the driver produces the following logs:

    317  [main] INFO  org.mongodb.driver.client - MongoClient with metadata {"driver": {"name": "<driver-name>", "version": "<driver-version>"}, "os": {"type": "<os-type>", "name": "<os-name>", "architecture": "<architecture>", "version": "<os-version>"}, "platform": "<platform-info>"} created with settings <MongoClientSettings>
    345  [cluster-ClusterId{value='<cluster-id>', description='null'}-<MongoDB hostname>] INFO  org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=<MongoDB hostname>, type=<server-type>, cryptd=false, state=CONNECTED, ok=true, minWireVersion=0, maxWireVersion=<max-wire-version>, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=<round-trip-nanos>, minRoundTripTimeNanos=<min-round-trip-nanos}
    

    I substituted settings with placeholders.

    The same applies for log4j example:

    21:19:25.696 [main] INFO  org.mongodb.driver.client - MongoClient with metadata {"driver": {"name": "<driver-name>", "version": "<driver-version>"}, "os": {"type": "<os-type>", "name": "<os-name>", "architecture": "<architecture>", "version": "<os-version>"}, "platform": "<platform-info>"} created with settings <MongoClientSettings>
    21:19:25.710 [cluster-ClusterId{value='<cluster-id>', description='null'}-<MongoDB hostname>] INFO  org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=<MongoDB hostname>, type=<server-type>, cryptd=false, state=CONNECTED, ok=true, minWireVersion=0, maxWireVersion=<max-wire-version>, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=<round-trip-nanos>, minRoundTripTimeNanos=<min-round-trip-nanos}
    


    .. code-block:: none
    :copyable: false
    Copy link
    Member

    @vbabanin vbabanin Jul 23, 2025

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Could you clarify why the log example was removed? We could use log4j example from this comment: #115 (comment)

    Copy link
    Collaborator Author

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    This was a pure miss on my end, will fix!


    ...
    12:14:55.853 [main] DEBUG org.mongodb.driver.connection - Opened connection [connectionId{localValue:3, serverValue:3}] to <MongoDB hostname>
    Copy link
    Member

    @vbabanin vbabanin Jul 23, 2025

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    This log line is no longer present in newer drivers. We can substitute this line with:

    12:14:55.833 [main] DEBUG org.mongodb.driver.connection - Checkout started for connection to <MongoDB hostname>
    12:14:55.834 [main] DEBUG org.mongodb.driver.connection - Connection created: address=<MongoDB hostname>, driver-generated ID=3
    12:14:55.836 [main] DEBUG org.mongodb.driver.connection - Connection ready: address=<MongoDB hostname>, driver-generated ID=3, established in=4 ms
    12:14:55.843 [main] DEBUG org.mongodb.driver.connection - Connection checked out: address=<MongoDB hostname>, driver-generated ID=3, duration=9 ms
    

    Comment on lines 353 to 354
    977 [main] INFO org.mongodb.driver.connection - Opened connection [connectionId{localValue:7, serverValue:<your server value>}] to <your connection uri>
    Copy link
    Member

    @vbabanin vbabanin Jul 23, 2025

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    These logs are no longer present and don’t align with the text above, which states that DEBUG level is enabled.

    We should update the example to reflect the configuration suggested in the comment above: discussion_r2224312327

    When that configuration is applied, the driver produces the following logs - I suggest we use those in the example. What do you think?

    255  [main] DEBUG org.mongodb.driver.connection - Connection pool created for <MongoDB hostname> using options <connection-pool-options>  
    301  [cluster-ClusterId{value='<cluster-id>', description='null'}-<MongoDB hostname>] DEBUG org.mongodb.driver.connection - Connection pool ready for <MongoDB hostname>  
    321  [main] DEBUG org.mongodb.driver.connection - Checkout started for connection to <MongoDB hostname>  
    323  [main] DEBUG org.mongodb.driver.connection - Connection created: address=<MongoDB hostname>, driver-generated ID=3  
    335  [main] DEBUG org.mongodb.driver.connection - Connection ready: address=<MongoDB hostname>, driver-generated ID=3, established in=<connect-duration> ms  
    336  [main] DEBUG org.mongodb.driver.connection - Connection checked out: address=<MongoDB hostname>, driver-generated ID=3, duration=<checkout-duration> ms  
    363  [main] DEBUG org.mongodb.driver.connection - Connection checked in: address=<MongoDB hostname>, driver-generated ID=3 
    

    Comment on lines 390 to 391
    15:40:23.159 [main] INFO org.mongodb.driver.connection - Opened connection [connectionId{localValue:7, serverValue:<your server value>}] to <your connection uri>
    Copy link
    Member

    @vbabanin vbabanin Jul 23, 2025

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    These logs are no longer present and don’t align with the text above, which states that DEBUG level is enabled.

    We should update the example to reflect the configuration suggested in the comment above: discussion_r2224256906

    When that configuration is applied, the driver produces the following logs - I suggest we use those in the example. What do you think?

    21:27:17.035  [main] DEBUG org.mongodb.driver.connection - Connection pool created for <MongoDB hostname> using options <connection-pool-options>  
    21:27:17.058  [cluster-ClusterId{value='<cluster-id>', description='null'}-<MongoDB hostname>] DEBUG org.mongodb.driver.connection - Connection pool ready for <MongoDB hostname>  
    21:27:17.064  [main] DEBUG org.mongodb.driver.connection - Checkout started for connection to <MongoDB hostname>  
    21:27:17.069  [main] DEBUG org.mongodb.driver.connection - Connection created: address=<MongoDB hostname>, driver-generated ID=3  
    21:27:17.075  [main] DEBUG org.mongodb.driver.connection - Connection ready: address=<MongoDB hostname>, driver-generated ID=3, established in=<connect-duration> ms  
    21:27:17.075  [main] DEBUG org.mongodb.driver.connection - Connection checked out: address=<MongoDB hostname>, driver-generated ID=3, duration=<checkout-duration> ms  
    21:27:17.086  [main] DEBUG org.mongodb.driver.connection - Connection checked in: address=<MongoDB hostname>, driver-generated ID=3 
    

    </encoder>
    </appender>
    <logger name="org.mongodb.driver.connection" level="INFO" additivity="true"/>
    Copy link
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    It is mentioned above "the following example disables the root logger and sets the log level for the ``org.mongodb.driver.connection`` logger to ``DEBUG``", thus we have to set DEBUG level in configuration, not INFO.

    Suggested change
    <logger name="org.mongodb.driver.connection" level="INFO" additivity="true"/>
    <logger name="org.mongodb.driver.connection" level="DEBUG" additivity="true"/>

    </Appenders>
    <Loggers>
    <Logger name="org.mongodb.driver.connection" level="INFO"/>
    Copy link
    Member

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    It is mentioned above "the following example disables the root logger and sets the log level for the org.mongodb.driver.connection logger to DEBUG", thus we have to set DEBUG level in configuration, not INFO.

    Suggested change
    <Logger name="org.mongodb.driver.connection" level="INFO"/>
    <Logger name="org.mongodb.driver.connection" level="DEBUG"/>

    @mcmorisi mcmorisi requested a review from vbabanin July 23, 2025 19:14
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    None yet
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    4 participants