英文:
Prevent console logging from external package .NET
问题
我们正在使用一个外部包(Microsoft.Azure.Kusto.Data),它正在向控制台输出大量日志。我们正在使用控制台日志提供程序,它会将所有写入控制台的内容都存储起来。这个包似乎没有使用记录器,可能是直接使用 Console.WriteLine 或类似的方式写入控制台,因此更改日志级别无法帮助。
有没有办法阻止特定的包向控制台输出?
下面是在 appsettings.json 中添加到 loglevel 的内容,但没有起作用:
"Microsoft.Azure.Kusto.Data": "Warning"
虽然对其他包有效。
英文:
We're using an external package (Microsoft.Azure.Kusto.Data) which is clogging up the console with tons of logs. We are using console logging provider and stores everything that's written to console. The package doesn't seem to use a logger, it's probably more directly writing to console with Console.WriteLine or similar, so changing log level doesn't help.
Is there a way to prevent a specific package to output to console?
Here's a screenshot from the logging in vs code,the two upper logs (starting with P.*) are from the kusto package while the other two (tagged with info) are our own logs.
Adding this to loglevel in appsettings.json did nothing:
"Microsoft.Azure.Kusto.Data": "Warning"
While it worked for other packages.
答案1
得分: 0
这似乎部分原因是由Azure Data Explorer Tracing引起的,添加以下代码片段可以消除大部分日志:
using Kusto.Cloud.Platform.Utils;
...
TraceSourceManager.SetTraceVerbosityForAll(TraceVerbosity.Error);
尽管在连接时仍会收到来自“Tweaks”的日志:
但这只会发生一次,所以我可以暂时接受。
英文:
This seems to (partially) be caused by Azure Data Explorer Tracing and adding this snippet got rid of most of the logs:
using Kusto.Cloud.Platform.Utils;
...
TraceSourceManager.SetTraceVerbosityForAll(TraceVerbosity.Error);
Though I still get logs from "Tweaks" when connecting:
That only happens once so I can live with that for now.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论