Cloud Run 上的 ASP.NET Core 6 应用未将日志路由到 Cloud Logging
我在 Cloud Run 上的容器中运行的 ASP.NET Core 6.0 网站配置为通过调用 AddGoogleDiagnosticsForAspNetCore(...)
来记录到 Google Cloud Logging。
这适用于我的生产 Cloud Run 网站,但不适用于开发测试。两个服务帐户都具有日志编写者角色。
My ASP.NET Core 6.0 website running in a container on Cloud Run is configured to log to Google Cloud Logging by way of a call to AddGoogleDiagnosticsForAspNetCore(...)
.
This works for my production Cloud Run website but not for dev-test. Both service accounts have the Logs Writer role.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错是我的。是的,这个问题毫无帮助,尽管公平地说,这个问题没有太多可移动的部分*。
我的代码否定了生产检查。我没能发现
!
,并且因为它在生产中可以工作这一事实而分散了我的注意力,而当它最初在生产中无法工作时,这是因为 IAM 权限。它可能在生产中工作,因为a)部署的代码较旧,不同b)其配置的某些内容正在启用控制台记录器。
查找故障涉及添加一个控制器操作,以从
IServiceProvider
获取并返回一个ILoggerProvider
,当由curl
调用时,它为 null,这让我查看再次查看应该注册此类型的代码,即上面的代码。结论:移动部件不多 = 可能是开发人员错误。
*我有这样的想法,如果每个人总是发布他们所有的问题,然后给出解决方案,无论它们看起来多么愚蠢,我们都会有一个很好的资源。我的大部分堆栈代表都来自回答我自己的问题。
The fault was mine. And yes, the question was unhelpful, though in fairness there aren't many moving parts to the problem*.
My code was negating the production check. I failed to spot the
!
and was distracted by the fact that it works in production, and that when it originally didn't work in production it was because of IAM permissions.It possibly works in production because a) the deployed code is older, different b) something about its configuration is enabling the console logger.
Finding the fault involved adding a controller action to get and return an
ILoggerProvider
from theIServiceProvider
which was null when called bycurl
, causing me to look again at the code which was supposed to register this type, the code above.In conclusion: not many moving parts = probably developer error.
*I have this idea that if everyone always posted all their problems and then the solutions, however dumb it makes them appear, we'd have a great resource. Most of my stack rep comes from answering my own questions.