工作服务中的事件登录未发布到Azure Application Insight

工作服务中的事件登录未发布到Azure Application Insight,azure,windows-services,azure-application-insights,asp.net-core-3.1,event-log,Azure,Windows Services,Azure Application Insights,Asp.net Core 3.1,Event Log,我正在构建一个Worker服务作为Windows服务。我使用EventLog进行日志记录。我还想添加ApplicationInsights来记录事件。我遵循本文,使用Nuget安装SDK,并按要求设置所有内容。这是我的程序.cs配置 public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)

我正在构建一个Worker服务作为Windows服务。我使用
EventLog
进行日志记录。我还想添加
ApplicationInsights
来记录事件。我遵循本文,使用Nuget安装SDK,并按要求设置所有内容。这是我的
程序.cs
配置

public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)                
            .ConfigureServices((hostContext, services) =>
            {
                services.AddHostedService<Worker>();
                services.AddApplicationInsightsTelemetryWorkerService();
                services.CustomeDependencyInjection();
            })
            .UseWindowsService()
            .ConfigureLogging(logging =>
            {
                logging.AddEventLog(eventLogSetting =>
                {
                    eventLogSetting.LogName = "MyTestEventLog";
                    eventLogSetting.SourceName = "MyTestEventApp";
                });
            });
下面是
worker.cs
文件中的日志记录示例

{
  "ApplicationInsights": {
      "InstrumentationKey": "bd******-****-****-****-***********b"
  },
  Logging": {
    "LogLevel": {
    "Default": "Information",
    "Microsoft": "Information",
    "Microsoft.Hosting.Lifetime": "Information"
    },
    "EventLog": {
      "LogLevel": {
      "Default": "Information",
      "Microsoft": "Information",
      "Microsoft.Hosting.Lifetime": "Information"
      }
    }
  }
}
public Worker(ILogger<Worker> logger, TelemetryClient tc)
{
        _logger = logger;
        this.tc = tc;
 }
 public Task StartAsync(CancellationToken cancellationToken)
 {
        this._logger.LogInformation("In Start");
        using (tc.StartOperation<RequestTelemetry>("Operation"))
        {
            /** 
                my service starting code 
            **/
            this._logger.LogInformation("Service is being started");
            tc.TrackEvent("Worker service starting operation completed.");
        }
        this._logger.LogInformation( "Service Started");
        return Task.CompletedTask;
 }
公共工作者(ILogger记录器、遥测客户端tc)
{
_记录器=记录器;
this.tc=tc;
}
公共任务StartSync(CancellationToken CancellationToken)
{
此._.logger.LogInformation(“启动中”);
使用(tc.启动操作(“操作”))
{
/** 
我的服务启动码
**/
此._logger.LogInformation(“服务正在启动”);
tc.TrackEvent(“工人服务启动操作完成”);
}
此._logger.LogInformation(“服务已启动”);
返回Task.CompletedTask;
}
当我运行应用程序时,我可以看到一个
customEvent
。我还可以看到
请求
事件。但是我在
跟踪
中找不到任何我希望使用
\u记录器
发送的信息。我检查了输出窗口,也没有发现针对
\u logger.LogInformation
发送任何遥测信息


我在这里做错了什么?我如何使记录器信息可用于
应用程序指示灯
?还是我没有查看正确的位置?

Application Insight默认将
Warning
作为日志级别。由于您使用级别
信息进行跟踪
,因此需要使用appsettings.json文件配置应用程序洞察:

{
“应用程序说明”:{
“InstrumentationKey:“bd******-***-***-***-***-***-***-***-*********-************b”
},
“日志记录”:{
“日志级别”:{
“默认值”:“信息”,
“Microsoft”:“信息”,
“Microsoft.Hosting.Lifetime”:“信息”
},
“应用程序说明”:{
“日志级别”:{
“默认值”:“信息”
}
}
“事件日志”:{
“日志级别”:{
“默认值”:“信息”,
“Microsoft”:“信息”,
“Microsoft.Hosting.Lifetime”:“信息”
}
}
}
}

Application Insight默认将
警告
作为日志级别。由于您使用级别
信息进行跟踪
,因此需要使用appsettings.json文件配置应用程序洞察:

{
“应用程序说明”:{
“InstrumentationKey:“bd******-***-***-***-***-***-***-***-*********-************b”
},
“日志记录”:{
“日志级别”:{
“默认值”:“信息”,
“Microsoft”:“信息”,
“Microsoft.Hosting.Lifetime”:“信息”
},
“应用程序说明”:{
“日志级别”:{
“默认值”:“信息”
}
}
“事件日志”:{
“日志级别”:{
“默认值”:“信息”,
“Microsoft”:“信息”,
“Microsoft.Hosting.Lifetime”:“信息”
}
}
}
}

这很有效。谢谢,行得通。谢谢