gpt4 book ai didi

logging - .NetCore 日志在 GCP Stackdriver 中输出错误的严重性

转载 作者:行者123 更新时间:2023-12-04 04:01:24 26 4
gpt4 key购买 nike

.netcore 应用程序的默认日志条目被写入标准输出并由 GCP Stackdriver 解释为信息消息,即使它是一个错误。有没有办法将 .netcore 错误写入 stderr 或以某种方式配置它们,以便 Stackdriver 将它们解释为错误?
Stackdriver 日志条目:
Stackdriver logs
.netcore 应用程序日志条目:
netcore app logs

最佳答案

每 Panagiotis Kanavos@:

If you insist on writing to console you'll have to remove the default console logger and add another one. The Microsoft.Extensions.Logging.Console logger is very basic, with a hard-coded format that writes parts of a single event in different lines. It can't be customised and isn't meant to - it's only meant to be the most basic default. Serilog's Console provider offers extensive customisation but why use the console when you can already send events to StackDriver?


根据 Kiramm@,这确实解决了最初的问题:

I removed the default console logger and added Google's logger factory and the Stackdriver started interpreting log entries severity correctly

关于logging - .NetCore 日志在 GCP Stackdriver 中输出错误的严重性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63016961/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com