我一直试图过滤掉我的ServiceBus触发的网络作业在应用程序洞察中发送的信息消息。这些消息由以下两条日志组成:
ReceiveBatchAsync start.MessageCount =1
ReceiveBatchAsync完成。收到了“0”消息。LockTokens =
我的目标是只记录我在代码中记录的信息跟踪,而忽略来自Azure.Messaging.ServiceBus的日志。我怎样才能做到这一点?
到目前为止,我已经尝试在我的program.cs文件中使用以下代码添加一个过滤器
b.AddFilter("Azure.Messaging.ServiceBus", LogLevel.Warning);我还尝试在我的appsettings.json文件中添加以下设置
"Logging": {
"LogLevel": {
"Default": "Information",
"Azure.Messaging.ServiceBus": "Warning"
}
},至于我的设置,我使用的是下列令人关注的软件包:
下面的代码是我在program.cs文件中的日志配置。

发布于 2022-11-18 08:51:00
我在过滤一些服务总线或EFCore日志时遇到了同样的问题。我能够部分解决这个问题,在日志配置代码中添加一些硬编码的过滤器:
builder.ConfigureLogging((context, b) => {
// If the key exists in settings, use it to enable Application Insights.
string instrumentationKey = context.Configuration["EASY_APPINSIGHTS_INSTRUMENTATIONKEY"];
if (!string.IsNullOrEmpty(instrumentationKey)) {
b.AddApplicationInsightsWebJobs(o => o.InstrumentationKey = instrumentationKey);
}
b.AddConsole();
b.AddFilter("Azure.Messaging.ServiceBus", LogLevel.Error);
b.AddFilter("Microsoft.EntityFrameworkCore", LogLevel.Error);
});但是,我想知道如何在从AppService的设置更新设置时设置日志记录。
https://stackoverflow.com/questions/72963764
复制相似问题