过滤 SignalR ping 消息
在我的 ASP.NET SignalR(.NET 7 WebApplication with Serilog)中,日志不断填满:
[INF] 请求开始 HTTP/1.1 POST http://127.0.0.1:5000/hubs/agentshub?id=su3OANTvP1YtU2i90eK1rA - 11
[INF] 请求已完成 HTTP/1.1 POST http://127.0.0.1:5000/hubs/agentshub?id=su3OANTvP1YtU2i90eK1rA - 11 - 200 0 文本/纯文本 1.1589ms
由于在这些消息之前或之后没有来自集线器的其他消息,我假设这些只是 SignalR 内部 ping。从更详细的日志记录中似乎可以明显看出这一点。
我的问题是如何过滤掉这些 ping 消息,同时保留其他 SignalR 集线器请求消息?
我尝试过:
.MinimumLevel.Override("Microsoft.AspNetCore.SignalR", Serilog.Events.LogEventLevel.Debug)
.MinimumLevel.Override("Microsoft.AspNetCore.Http.Connections", Serilog.Events.LogEventLevel.Debug);
但没有运气。
In my ASP.NET SignalR (.NET 7 WebApplication with Serilog), logs keep filling up with:
[INF] Request starting HTTP/1.1 POST http://127.0.0.1:5000/hubs/agentshub?id=su3OANTvP1YtU2i90eK1rA - 11
[INF] Request finished HTTP/1.1 POST http://127.0.0.1:5000/hubs/agentshub?id=su3OANTvP1YtU2i90eK1rA - 11 - 200 0 text/plain 1.1589ms
As there are no other messages from the hub before or after these messages, I assume these are simply SignalR internal pings. As seems to be evident from more verbose logging.
My question is how to filter out these ping messages while keeping other SignalR hub request messages?
I tried:
.MinimumLevel.Override("Microsoft.AspNetCore.SignalR", Serilog.Events.LogEventLevel.Debug)
.MinimumLevel.Override("Microsoft.AspNetCore.Http.Connections", Serilog.Events.LogEventLevel.Debug);
But no luck.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
然后:(
您可能需要根据事件的结构/准确地识别 ping 的内容来调整表达式。)
Then:
(You might need to tweak the expression depending on the structure of the events/what identifies a ping, exactly.)