From 79a76e6c50b8f4bd50bb77011c641f3cff65b4b1 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Fri, 7 Feb 2025 08:47:20 -0800 Subject: [PATCH 1/8] add new logger --- source/fundamentals/logging.txt | 174 +++++++++++++++++++++--- source/includes/fundamentals/logging.js | 27 ++++ 2 files changed, 182 insertions(+), 19 deletions(-) create mode 100644 source/includes/fundamentals/logging.js diff --git a/source/fundamentals/logging.txt b/source/fundamentals/logging.txt index eed3d00d5..44a39f1f6 100644 --- a/source/fundamentals/logging.txt +++ b/source/fundamentals/logging.txt @@ -7,7 +7,7 @@ Logging :values: reference .. meta:: - :keywords: code example, deprecated, replace + :keywords: code example, log, information, monitor .. contents:: On this page :local: @@ -15,29 +15,165 @@ Logging :depth: 1 :class: singlecols -.. important:: +Overview +-------- - The driver doesn't use the logger in versions 4.0 and later. - Attempting to use prior logger settings in this version won't print - anything in the log. +In this guide, you can learn how to configure logging options with the +{+driver-short+}. The driver allows you to log information that have the +following severity levels: - Instead, see our monitoring guides: +- ``emergency`` +- ``alert`` +- ``critical`` +- ``error`` +- ``warn`` +- ``notice`` +- ``info`` +- ``debug`` +- ``trace`` +- ``off`` - - :ref:`Command Monitoring ` - - :ref:`Cluster Monitoring ` - - :ref:`Connection Pool Monitoring ` +The preceding list is ordered in decreasing severity level. Specifying a severity +level also logs all messages with lower severity levels. For example, setting +the log level to ``debug`` also logs messages with a severity level of +``trace``. -Temporary Alternative ---------------------- +The lower the severity level you specify, the more information the driver logs, +which impacts performance of your application. For the best performance, ensure +that you set the severity to the highest severity level that provides the information +your application needs. -We are developing a new logging framework. In the meantime, you can output monitor events -by using the following snippet: +Configuration +------------- -.. code-block:: javascript +You can configure logging in the {+driver-short+} without code changes by +specifying environment variables. You can also configure logging +programmatically by specifying client options in the ``MongoClient`` +constructor. - const uri = "mongodb+srv://:@?writeConcern=majority"; - const client = new MongoClient(uri, { monitorCommands:true }); +.. note:: - client.on('commandStarted', (event) => console.debug(event)); - client.on('commandSucceeded', (event) => console.debug(event)); - client.on('commandFailed', (event) => console.debug(event)); + Because connection strings are often shared among a deployment of different + appications that might have different logging support, we do not recommend + using a connection string to configure logging. + +Environment Variables +~~~~~~~~~~~~~~~~~~~~~ + +You can configure logging for different components of the driver by specifying +a severity level in one or more of the following environment variables: + +- ``MONGODB_LOG_COMMAND`` +- ``MONGODB_LOG_TOPOLOGY`` +- ``MONGODB_LOG_SERVER_SELECTION`` +- ``MONGODB_LOG_CONNECTION`` +- ``MONGODB_LOG_CLIENT`` + +If you don't specify any of the preceding environment variables, the driver uses +the value of ``MONGODB_LOG_ALL``, which if not specified, is implicitly set to +``off``. + +.. tip:: + + Logging at tge command level is the most performance-heavy logging option + due to the frequency in which commands are sent to the server. Only + specify this option if necessary for your application. + +The following example sets the log level for all components to ``debug`` except +for ``MONGODB_LOG_COMMAND``: + +.. code-block:: bash + + export MONGODB_LOG_ALL="debug" + export MONGODB_LOG_COMMAND="off" + +You can specify whether the driver logs to ``stderr`` or ``stdout`` by setting +the ``MONGODB_LOG_PATH`` environment variable to ``"stderr"`` or ``"stdout"``. +By default, the driver logs to ``stdout``. + +The driver stringifies logged documents by using EJSON, which limits strings to +1000 characters by default. You can specify a maximum document length for your +logger by specifying the ``MONGODB_LOG_MAX_DOCUMENT`` environment variable. Set +this variable to ``0`` to perform no truncation. + +Client Options +~~~~~~~~~~~~~~ + +You can configure logging programmatically by specifying client options in the +``MongoClient`` constructor. Because client options take precedence over environment +variables, only specify them in the client if you want to override any +environment variables. + +.. tip:: + + If your application relies on the format of ``stdout`` or ``stderr``, we + recommend configuring logging by using client options to avoid conflicts with + your application user's environment variables. + +You can specify which component to configure logging for by specifying one or more of the +following client options: + +- ``all`` +- ``command`` +- ``topology`` +- ``serverSelection`` +- ``connection`` +- ``client`` +- ``default`` + +To specify a log level for a component, set the +``mongodbLogComponentSeverities`` option to an object that contains the +component and your desired severity level. The following example sets the log +level for all components to ``debug`` except for ``command``: + +.. literalinclude:: /includes/fundamentals/logging.js + :language: javascript + :start-after: start-logger-client-options + :end-before: end-logger-client-options + +You can specify whether the driver logs to ``stderr`` or ``stdout`` by setting +the ``mongodbLogPath`` option to ``"stderr"`` or ``"stdout"``. You can also +specify a custom log destination. The following example creates a custom log +destination: + +.. literalinclude:: /includes/fundamentals/logging.js + :language: javascript + :start-after: start-custom-logger + :end-before: end-custom-logger + +If your function throws an error in the write operation, the thrown error +ends the logger. Because of this, we recommend that you handle errors by +making the write function a no-op rather than throwing an error, as shown in +the preceding example. + +.. note:: + + Logging can exhaust disk space if the proper log rotation system is not in + place. We recommend that you connect your custom write function to a known + logging library. + +The driver stringifies logged documents by using EJSON, which limits strings to +1000 characters by default. You can specify a maximum document length for your +logger by specifying the ``mongodbLogMaxDocumentLength`` option. Set +this option to ``0`` to perform no truncation. + +Additional Information +---------------------- + +For more information about monitoring with the {+driver-short+}, see the +following monitoring guides: + +- :ref:`Command Monitoring ` +- :ref:`Cluster Monitoring ` +- :ref:`Connection Pool Monitoring ` + +API Documentation +~~~~~~~~~~~~~~~~~ + +To learn more about any of the options or types discussed in this guide, see the +following API documentaion: + +- `MongoClientOptions <{+api+}/interfaces/MongoClientOptions.html>`__ +- `mongodbLogComponentSeverities <{+api+}/interfaces/MongoClientOptions.html#mongodbLogComponentSeverities>`__ +- `mongodbLogMaxDocumentLength <{+api+}/interfaces/MongoClientOptions.html#mongodbLogMaxDocumentLength>`__ +- `mongodbLogPath <{+api+}/interfaces/MongoClientOptions.html#mongodbLogPath>`__ \ No newline at end of file diff --git a/source/includes/fundamentals/logging.js b/source/includes/fundamentals/logging.js new file mode 100644 index 000000000..49d9e4dbb --- /dev/null +++ b/source/includes/fundamentals/logging.js @@ -0,0 +1,27 @@ +// start-logger-client-options +const client = new MongoClient(", { + mongodbLogComponentSeverities: { + all: "debug", + command: "off" + } +}); +// end-logger-client-options + +// start-custom-logger +import fs from 'node:fs/promises'; +import util from 'node:util'; + +const mongodbLogPath = { + file: await fs.open(`./server-${+new Date()}.logs`, 'w'), + async write(log) { + try { + await this.file?.appendFile(util.inspect(log) + '\n'); + } catch (fileError) { + console.log('cannot log anymore', fileError); + this.file = null; + } + } +} + +const client = new MongoClient("...", { mongodbLogPath }); +// end-custom-logger \ No newline at end of file From ec959f23aad8b355189c09ce8383e71be6cf7e80 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Fri, 7 Feb 2025 10:28:59 -0800 Subject: [PATCH 2/8] edits --- source/fundamentals/logging.txt | 16 ++++++++-------- source/includes/fundamentals/logging.js | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/source/fundamentals/logging.txt b/source/fundamentals/logging.txt index 44a39f1f6..a31cdd94f 100644 --- a/source/fundamentals/logging.txt +++ b/source/fundamentals/logging.txt @@ -12,15 +12,15 @@ Logging .. contents:: On this page :local: :backlinks: none - :depth: 1 + :depth: 2 :class: singlecols Overview -------- In this guide, you can learn how to configure logging options with the -{+driver-short+}. The driver allows you to log information that have the -following severity levels: +{+driver-short+}. The driver allows you to log information that are categorized +by following severity levels: - ``emergency`` - ``alert`` @@ -33,10 +33,10 @@ following severity levels: - ``trace`` - ``off`` -The preceding list is ordered in decreasing severity level. Specifying a severity -level also logs all messages with lower severity levels. For example, setting -the log level to ``debug`` also logs messages with a severity level of -``trace``. +The preceding list is ordered by decreasing severity level. Specifying a severity +level also logs all messages with higher severity levels. For example, setting +the log level to ``critical`` also logs messages with severity levels of +``emergency`` and ``alert``. The lower the severity level you specify, the more information the driver logs, which impacts performance of your application. For the best performance, ensure @@ -75,7 +75,7 @@ the value of ``MONGODB_LOG_ALL``, which if not specified, is implicitly set to .. tip:: - Logging at tge command level is the most performance-heavy logging option + Logging at the command level is the most performance-heavy logging option due to the frequency in which commands are sent to the server. Only specify this option if necessary for your application. diff --git a/source/includes/fundamentals/logging.js b/source/includes/fundamentals/logging.js index 49d9e4dbb..10d025881 100644 --- a/source/includes/fundamentals/logging.js +++ b/source/includes/fundamentals/logging.js @@ -1,5 +1,5 @@ // start-logger-client-options -const client = new MongoClient(", { +const client = new MongoClient("", { mongodbLogComponentSeverities: { all: "debug", command: "off" @@ -23,5 +23,5 @@ const mongodbLogPath = { } } -const client = new MongoClient("...", { mongodbLogPath }); +const client = new MongoClient("", { mongodbLogPath }); // end-custom-logger \ No newline at end of file From e597876435f90f17f1cb96b755447f48b52360cf Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Mon, 10 Feb 2025 08:15:56 -0800 Subject: [PATCH 3/8] feedback + formatting --- source/fundamentals/logging.txt | 83 ++++++++++++++++++------- source/includes/fundamentals/logging.js | 24 ++++++- 2 files changed, 84 insertions(+), 23 deletions(-) diff --git a/source/fundamentals/logging.txt b/source/fundamentals/logging.txt index a31cdd94f..63ea78065 100644 --- a/source/fundamentals/logging.txt +++ b/source/fundamentals/logging.txt @@ -18,9 +18,9 @@ Logging Overview -------- -In this guide, you can learn how to configure logging options with the -{+driver-short+}. The driver allows you to log information that are categorized -by following severity levels: +In this guide, you can learn how to configure a logger in the +{+driver-short+}. The driver allows you to log information categorized +at following severity levels: - ``emergency`` - ``alert`` @@ -39,9 +39,7 @@ the log level to ``critical`` also logs messages with severity levels of ``emergency`` and ``alert``. The lower the severity level you specify, the more information the driver logs, -which impacts performance of your application. For the best performance, ensure -that you set the severity to the highest severity level that provides the information -your application needs. +which might impact the performance of your application. Configuration ------------- @@ -63,11 +61,12 @@ Environment Variables You can configure logging for different components of the driver by specifying a severity level in one or more of the following environment variables: -- ``MONGODB_LOG_COMMAND`` -- ``MONGODB_LOG_TOPOLOGY`` -- ``MONGODB_LOG_SERVER_SELECTION`` -- ``MONGODB_LOG_CONNECTION`` -- ``MONGODB_LOG_CLIENT`` +- ``MONGODB_LOG_ALL``: Logs all events +- ``MONGODB_LOG_COMMAND``: Logs all commands sent to the server +- ``MONGODB_LOG_TOPOLOGY``: Logs any changes to the cluster topology +- ``MONGODB_LOG_SERVER_SELECTION``: Logs the server selection process +- ``MONGODB_LOG_CONNECTION``: Logs all connection pool events +- ``MONGODB_LOG_CLIENT``: Logs all client events If you don't specify any of the preceding environment variables, the driver uses the value of ``MONGODB_LOG_ALL``, which if not specified, is implicitly set to @@ -87,15 +86,33 @@ for ``MONGODB_LOG_COMMAND``: export MONGODB_LOG_ALL="debug" export MONGODB_LOG_COMMAND="off" +Log Location +```````````` + You can specify whether the driver logs to ``stderr`` or ``stdout`` by setting -the ``MONGODB_LOG_PATH`` environment variable to ``"stderr"`` or ``"stdout"``. +the ``MONGODB_LOG_PATH`` environment variable to ``"stderr"`` or ``"stdout"``, +as shown in the following example: + +.. code-block:: bash + + export MONGODB_LOG_PATH="stderr" + By default, the driver logs to ``stdout``. +Document Length +``````````````` + The driver stringifies logged documents by using EJSON, which limits strings to 1000 characters by default. You can specify a maximum document length for your logger by specifying the ``MONGODB_LOG_MAX_DOCUMENT`` environment variable. Set this variable to ``0`` to perform no truncation. +The following example sets the maximum document length to 500 characters: + +.. code-block:: bash + + export MONGODB_LOG_MAX_DOCUMENT_LENGTH=500 + Client Options ~~~~~~~~~~~~~~ @@ -113,13 +130,12 @@ environment variables. You can specify which component to configure logging for by specifying one or more of the following client options: -- ``all`` -- ``command`` -- ``topology`` -- ``serverSelection`` -- ``connection`` -- ``client`` -- ``default`` +- ``all``: Logs all events +- ``command``: Logs all commands sent to the server +- ``topology``: Logs any changes to the cluster topology +- ``serverSelection``: Logs the server selection process +- ``connection``: Logs all connection pool events +- ``client``: Logs all client events To specify a log level for a component, set the ``mongodbLogComponentSeverities`` option to an object that contains the @@ -131,10 +147,22 @@ level for all components to ``debug`` except for ``command``: :start-after: start-logger-client-options :end-before: end-logger-client-options +Log Location +```````````` You can specify whether the driver logs to ``stderr`` or ``stdout`` by setting -the ``mongodbLogPath`` option to ``"stderr"`` or ``"stdout"``. You can also -specify a custom log destination. The following example creates a custom log -destination: +the ``mongodbLogPath`` option to ``"stderr"`` or ``"stdout"``, as shown in the +following example: + +.. literalinclude:: /includes/fundamentals/logging.js + :language: javascript + :start-after: start-log-location + :end-before: end-log-location + :emphasize-lines: 5-6 + +By default, the driver logs to ``stdout``. + +You can also specify a custom log destination. The following example creates a +custom log destination: .. literalinclude:: /includes/fundamentals/logging.js :language: javascript @@ -152,11 +180,22 @@ the preceding example. place. We recommend that you connect your custom write function to a known logging library. +Document Length +``````````````` + The driver stringifies logged documents by using EJSON, which limits strings to 1000 characters by default. You can specify a maximum document length for your logger by specifying the ``mongodbLogMaxDocumentLength`` option. Set this option to ``0`` to perform no truncation. +The following example sets the maximum document length to 500 characters: + +.. literalinclude:: /includes/fundamentals/logging.js + :language: javascript + :start-after: start-log-length + :end-before: end-log-length + :emphasize-lines: 5, 8 + Additional Information ---------------------- diff --git a/source/includes/fundamentals/logging.js b/source/includes/fundamentals/logging.js index 10d025881..ee5c02848 100644 --- a/source/includes/fundamentals/logging.js +++ b/source/includes/fundamentals/logging.js @@ -7,6 +7,15 @@ const client = new MongoClient("", { }); // end-logger-client-options +// start-log-location +const mongodbLogComponentSeverities = { + all: "debug" +}; + +const mongodbLogPath = "stderr"; +const client = new MongoClient("", { mongodbLogComponentSeverities, mongodbLogPath }); +// end-log-location + // start-custom-logger import fs from 'node:fs/promises'; import util from 'node:util'; @@ -24,4 +33,17 @@ const mongodbLogPath = { } const client = new MongoClient("", { mongodbLogPath }); -// end-custom-logger \ No newline at end of file +// end-custom-logger + +// start-log-length +const mongodbLogComponentSeverities = { +all: "debug" +}; + +const mongodbLogLength = 500; +const client = new MongoClient("", { + mongodbLogComponentSeverities, + mongodbLogLength + }); +// end-log-length + From 081fdea5a6d1f5e3971c3f74cb72e0d8306efa69 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Mon, 10 Feb 2025 08:26:20 -0800 Subject: [PATCH 4/8] code block formatting --- source/includes/fundamentals/logging.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/includes/fundamentals/logging.js b/source/includes/fundamentals/logging.js index ee5c02848..d56086217 100644 --- a/source/includes/fundamentals/logging.js +++ b/source/includes/fundamentals/logging.js @@ -13,7 +13,9 @@ const mongodbLogComponentSeverities = { }; const mongodbLogPath = "stderr"; -const client = new MongoClient("", { mongodbLogComponentSeverities, mongodbLogPath }); +const client = new MongoClient("", + { mongodbLogComponentSeverities, mongodbLogPath } +); // end-log-location // start-custom-logger From 38bff142e07f3b980a8946601ce10acbd3073d5b Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Mon, 10 Feb 2025 08:30:42 -0800 Subject: [PATCH 5/8] code block highlighting --- source/fundamentals/logging.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/fundamentals/logging.txt b/source/fundamentals/logging.txt index 63ea78065..b2dd4fe93 100644 --- a/source/fundamentals/logging.txt +++ b/source/fundamentals/logging.txt @@ -157,7 +157,7 @@ following example: :language: javascript :start-after: start-log-location :end-before: end-log-location - :emphasize-lines: 5-6 + :emphasize-lines: 5-8 By default, the driver logs to ``stdout``. From fa3edbf61f45946951c0e59ec87793462a869258 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Mon, 10 Feb 2025 10:49:28 -0800 Subject: [PATCH 6/8] format + feedback --- source/fundamentals/logging.txt | 4 ++-- source/includes/fundamentals/logging.js | 30 ++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/source/fundamentals/logging.txt b/source/fundamentals/logging.txt index b2dd4fe93..63362aac2 100644 --- a/source/fundamentals/logging.txt +++ b/source/fundamentals/logging.txt @@ -35,7 +35,7 @@ at following severity levels: The preceding list is ordered by decreasing severity level. Specifying a severity level also logs all messages with higher severity levels. For example, setting -the log level to ``critical`` also logs messages with severity levels of +the log level to ``critical`` also results in log messages with severity levels of ``emergency`` and ``alert``. The lower the severity level you specify, the more information the driver logs, @@ -105,7 +105,7 @@ Document Length The driver stringifies logged documents by using EJSON, which limits strings to 1000 characters by default. You can specify a maximum document length for your logger by specifying the ``MONGODB_LOG_MAX_DOCUMENT`` environment variable. Set -this variable to ``0`` to perform no truncation. +this variable to ``0`` to not perform truncation. The following example sets the maximum document length to 500 characters: diff --git a/source/includes/fundamentals/logging.js b/source/includes/fundamentals/logging.js index d56086217..c9189176d 100644 --- a/source/includes/fundamentals/logging.js +++ b/source/includes/fundamentals/logging.js @@ -1,9 +1,9 @@ // start-logger-client-options const client = new MongoClient("", { - mongodbLogComponentSeverities: { - all: "debug", - command: "off" - } + mongodbLogComponentSeverities: { + all: "debug", + command: "off" + } }); // end-logger-client-options @@ -13,7 +13,7 @@ const mongodbLogComponentSeverities = { }; const mongodbLogPath = "stderr"; -const client = new MongoClient("", +const client = new MongoClient("", { mongodbLogComponentSeverities, mongodbLogPath } ); // end-log-location @@ -23,15 +23,15 @@ import fs from 'node:fs/promises'; import util from 'node:util'; const mongodbLogPath = { - file: await fs.open(`./server-${+new Date()}.logs`, 'w'), - async write(log) { - try { - await this.file?.appendFile(util.inspect(log) + '\n'); - } catch (fileError) { - console.log('cannot log anymore', fileError); - this.file = null; + file: await fs.open(`./server-${+new Date()}.logs`, 'w'), + async write(log) { + try { + await this.file?.appendFile(util.inspect(log) + '\n'); + } catch (fileError) { + console.log('cannot log anymore', fileError); + this.file = null; + } } - } } const client = new MongoClient("", { mongodbLogPath }); @@ -39,13 +39,13 @@ const client = new MongoClient("", { mongodbLogPath }); // start-log-length const mongodbLogComponentSeverities = { -all: "debug" + all: "debug" }; const mongodbLogLength = 500; const client = new MongoClient("", { mongodbLogComponentSeverities, mongodbLogLength - }); +}); // end-log-length From 3cd5e781bcac8e687a03e03f4ed9b977668d8a29 Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Tue, 11 Feb 2025 08:33:18 -0800 Subject: [PATCH 7/8] tech review feedback --- source/fundamentals/logging.txt | 16 ++++++++-------- source/includes/fundamentals/logging.js | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/source/fundamentals/logging.txt b/source/fundamentals/logging.txt index 63362aac2..abf57e3c6 100644 --- a/source/fundamentals/logging.txt +++ b/source/fundamentals/logging.txt @@ -61,7 +61,7 @@ Environment Variables You can configure logging for different components of the driver by specifying a severity level in one or more of the following environment variables: -- ``MONGODB_LOG_ALL``: Logs all events +- ``MONGODB_LOG_ALL``: Specifies the default severity for any unset components - ``MONGODB_LOG_COMMAND``: Logs all commands sent to the server - ``MONGODB_LOG_TOPOLOGY``: Logs any changes to the cluster topology - ``MONGODB_LOG_SERVER_SELECTION``: Logs the server selection process @@ -76,7 +76,7 @@ the value of ``MONGODB_LOG_ALL``, which if not specified, is implicitly set to Logging at the command level is the most performance-heavy logging option due to the frequency in which commands are sent to the server. Only - specify this option if necessary for your application. + specify this option if necessary for debugging your application. The following example sets the log level for all components to ``debug`` except for ``MONGODB_LOG_COMMAND``: @@ -97,7 +97,7 @@ as shown in the following example: export MONGODB_LOG_PATH="stderr" -By default, the driver logs to ``stdout``. +By default, the driver logs to ``stderr``. Document Length ``````````````` @@ -118,8 +118,8 @@ Client Options You can configure logging programmatically by specifying client options in the ``MongoClient`` constructor. Because client options take precedence over environment -variables, only specify them in the client if you want to override any -environment variables. +variables, only specify them in the client if you no longer want the driver to +respond to environment variables. .. tip:: @@ -130,7 +130,7 @@ environment variables. You can specify which component to configure logging for by specifying one or more of the following client options: -- ``all``: Logs all events +- ``default``: Specifies the default severity for any unset components - ``command``: Logs all commands sent to the server - ``topology``: Logs any changes to the cluster topology - ``serverSelection``: Logs the server selection process @@ -159,7 +159,7 @@ following example: :end-before: end-log-location :emphasize-lines: 5-8 -By default, the driver logs to ``stdout``. +By default, the driver logs to ``stderr``. You can also specify a custom log destination. The following example creates a custom log destination: @@ -177,7 +177,7 @@ the preceding example. .. note:: Logging can exhaust disk space if the proper log rotation system is not in - place. We recommend that you connect your custom write function to a known + place. We recommend that you connect your custom write function to a popular logging library. Document Length diff --git a/source/includes/fundamentals/logging.js b/source/includes/fundamentals/logging.js index c9189176d..0cf12bd91 100644 --- a/source/includes/fundamentals/logging.js +++ b/source/includes/fundamentals/logging.js @@ -1,7 +1,7 @@ // start-logger-client-options const client = new MongoClient("", { mongodbLogComponentSeverities: { - all: "debug", + default: "debug", command: "off" } }); @@ -9,10 +9,10 @@ const client = new MongoClient("", { // start-log-location const mongodbLogComponentSeverities = { - all: "debug" + default: "debug" }; -const mongodbLogPath = "stderr"; +const mongodbLogPath = "stdout"; const client = new MongoClient("", { mongodbLogComponentSeverities, mongodbLogPath } ); @@ -39,7 +39,7 @@ const client = new MongoClient("", { mongodbLogPath }); // start-log-length const mongodbLogComponentSeverities = { - all: "debug" + default: "debug" }; const mongodbLogLength = 500; From 2a09beba2a3abf80bc179253e8628c2d2ad49afd Mon Sep 17 00:00:00 2001 From: Jordan Smith Date: Tue, 11 Feb 2025 12:41:26 -0800 Subject: [PATCH 8/8] add ref in wgats new --- source/fundamentals/logging.txt | 2 ++ source/whats-new.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/source/fundamentals/logging.txt b/source/fundamentals/logging.txt index abf57e3c6..430d046ed 100644 --- a/source/fundamentals/logging.txt +++ b/source/fundamentals/logging.txt @@ -1,3 +1,5 @@ +.. _node-logging: + ======= Logging ======= diff --git a/source/whats-new.txt b/source/whats-new.txt index 850eef748..cd3b3f43c 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -49,7 +49,7 @@ The {+driver-short+} v6.13 release includes the following features: env MONGODB_LOG_ALL=debug node server.mjs -.. TODO: To learn more, see the :ref:`Logging ` guide. + To learn more about logging, see the :ref:`Logging ` guide. - Improves command monitoring performance by removing deep copies of command and reply objects. Modifying the command and response values might lead to