Skip to content

Commit 6dc2dfe

Browse files
(DOCSP-18529): Add info on database tools logs
1 parent 3a0e4c6 commit 6dc2dfe

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

source/index.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,5 @@ Further Reading
134134
mongotop </mongotop>
135135
mongofiles </mongofiles>
136136
/installation/installation
137+
/logs
137138
/release-notes/database-tools-changelog

source/logs.txt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
===================
2+
Database Tools Logs
3+
===================
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
The {+dbtools+} print logs to stderr.
14+
15+
Stderr Examples
16+
---------------
17+
18+
The following examples show the results of :program:`mongoexport`
19+
operations and the information logged to stderr.
20+
21+
Successful ``mongoexport`` Operation
22+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23+
24+
Consider the following :program:`mongoexport` operation that
25+
produces a file called ``cakeSales.json`` from the contents
26+
of the ``test.cakeSales`` collection:
27+
28+
.. code-block:: sh
29+
30+
mongoexport --db=test --collection=cakeSales --out=cakeSales.json
31+
32+
:program:`mongoexport` logs the following information to stderr:
33+
34+
.. code-block:: none
35+
:copyable: false
36+
37+
2021-09-21T14:05:07.197-0400 connected to: mongodb://localhost/
38+
2021-09-21T14:05:07.203-0400 exported 6 records
39+
40+
Failed ``mongoexport`` Operation
41+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42+
43+
Consider the following :program:`mongoexport` operation that fails
44+
because it cannot connect to the target deployment:
45+
46+
.. code-block:: sh
47+
48+
mongoexport --host=notRealHost.example.net --port=27017 --username=someUser --authenticationDatabase=admin --collection=contacts --db=marketing --out=mdb1-examplenet.json
49+
50+
:program:`mongoexport` logs the following information to stderr:
51+
52+
.. code-block:: none
53+
:copyable: false
54+
55+
2021-09-21T14:35:30.125-0400 could not connect to server: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: notrealhost.example.net:27017, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp: lookup notrealhost.example.net: no such host }, ] }
56+
57+
Pipe Database Tools Logs to a File
58+
----------------------------------
59+
60+
You may want to output the contents of the stderr logs to a file
61+
for easier viewing, or to save the results of {+dbtools-short+}
62+
operations.
63+
64+
To pipe the stderr output to a file, append ``2> {fileName}``
65+
to your command.
66+
67+
Example
68+
~~~~~~~
69+
70+
The following command writes the output of a :program:`mongoexport`
71+
operation to a file called ``mongoexport.log``. In this example, the
72+
``mongoexport.log`` file is created in the same directory where the
73+
command is run.
74+
75+
.. code-block:: sh
76+
77+
mongoexport --db=test --collection=cakeSales --out=cakeSales.json 2> mongoexport.log
78+
79+
To view the contents of ``mongoexport.log``, open the file in a text
80+
editor.

0 commit comments

Comments
 (0)