我试图了解如何禁用mongodb关于ssl已弃用的警告消息。我确实在我的连接字符串中添加了——quiet标志,但它似乎没有帮助。
只是上下文-我正在写一个bash脚本与数据库交互,也许有一种方法来直接输出到一个文件或什么?我是个新手,所以请原谅我:)
{"t":{"$date":"2022-05-12T10:58:02.347Z"},"s":"W", "c":"CONTROL", "id":12123, "ctx":"main","msg":"Option: This name is deprecated. Please use the preferred name instead.","attr":{"deprecatedName":"ssl","preferredName":"tls"}}
{"t":{"$date":"2022-05-12T10:58:02.347Z"},"s":"W", "c":"CONTROL", "id":12123, "ctx":"main","msg":"Option: This name is deprecated. Please use the preferred name instead.","attr":{"deprecatedName":"sslPEMKeyFile","preferredName":"tlsCertificateKeyFile"}}
{"t":{"$date":"2022-05-12T10:58:02.347Z"},"s":"W", "c":"CONTROL", "id":12123, "ctx":"main","msg":"Option: This name is deprecated. Please use the preferred name instead.","attr":{"deprecatedName":"sslCAFile","preferredName":"tlsCAFile"}}
在您的bash中,任何命令输出都可以被过滤、修改、发送到文件,…
说明:
#!/bin/bash
# Eliminate all output
/bin/ls -c1 /etc >/dev/null
# Filter the output, remove all files containing the word "host"
/bin/ls -c1 /etc | grep -v host
# Send to a file
/bin/ls -c1 /etc >output_file
# Send to a file and see the messages on your terminal
/bin/ls -c1 /etc | tee output_file
# Hide only the error messages
/bin/ls -c1 /etc 2>/dev/null
# Send all output AND errors to a file
/bin/ls -c1 /etc >output_file 2>output_file
# Same as above, other syntax
/bin/ls -c1 /etc >output_file 2>&1
# Modify the output. Here if the filename contains "host", replace it by "AAAA"
/bin/ls -c1 /etc | sed 's/host/AAAA/'
您可以根据您的命令输出调整这些方法中的任何一种。