c# - 无法在遥测中找到 hangfire.Name

标签 c# hangfire

我需要从 Azure App Insight 中的 hangfire 中排除日志。引用这篇文章,App Insights: Disable SQL Dependency telemetry

if (telemetry.Type == "SQL"
    && telemetry.Name.ToLower().Contains("hangfire")
    && telemetry.Success.GetValueOrDefault(false))
{
    return;
}

当我对 telemetry.Name 进行故障排除时,我看不到 hangfire,因此它将照常处理遥测。 telemetry.Name 我得到的是 xx.xxx.xx.xx,xxx |我的服务

next.Process(item);

示例日志(修改版本,因为得到了ip地址)

10/25/2022, 10:57:10 PM

10/25/2022, 10:52:10 PM

10/25/2022, 10:52:10 PM

10/25/2022, 10:52:10 PM

10/25/2022, 10:52:10 PM

10/25/2022, 10:52:10 PM

10/25/2022, 10:52:10 PM

10/25/2022, 10:52:10 PM

10/25/2022, 10:52:10 PM

10/25/2022, 10:52:10 PM

10/25/2022, 10:47:10 PM

最佳答案

您可以通过在 appsettings.json 文件的 Logging 部分添加一个 "Hangfire": "None" 条目来停止 Hangfire 的日志记录.

"Logging": {
  "LogLevel": {
    "Default": "Information",
    "Hangfire": "None"
  }
}

关于c# - 无法在遥测中找到 hangfire.Name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74242448/

相关文章:

c# - XAML 设计器中的 "Method not found"错误

hangfire - 从数据库脚本触发重复的 Hangfire 作业

asp.net-mvc - Hangfire 作业中的 Url.Action

linq - 将单位 -> 单位转换为操作

c# - 多线程服务,BackgroundWorker vs ThreadPool?

c# - 使用 CaSTLe ActiveRecord 插入多行并忽略任何重复项的推荐方法

mongodb - 无法在 Visual Studio 2013 中引用 Hangfire.Mongo

c# - Hangfire 多台服务器

javascript - 我可以在没有相应 C# 对象的情况下在 API 上接收 JavaScript 对象吗?

c# - 将 mudblazor TreeView 绑定(bind)到对象