Azure服务结构应用程序日志未出现在应用程序洞察中 [英] Azure service fabric application logs not appearing in app insights

查看:11
本文介绍了Azure服务结构应用程序日志未出现在应用程序洞察中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VS模板附带的ServiceEventSource实现来记录消息。它会出现在诊断事件查看器中,但不会出现在配置的应用程序洞察实例中。 我确实在应用程序洞察实例中获得了其他平台事件,但我的应用程序日志记录中没有。

日志行示例-

ServiceEventSource.Current.ServiceMessage(this.Context, "Config deployment is disabled.");

除了使用Visual Studio上下文菜单配置应用程序洞察之外,我没有做任何其他事情。此外,在创建服务结构集群时,我确实提供了正确的检测密钥。

ApplicationInsights.config-

<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
  <InstrumentationKey>ac5a18e4-3750-46b4-ac10-2a887915b163</InstrumentationKey>
  <TelemetryInitializers>
    <Add Type="Microsoft.ApplicationInsights.ServiceFabric.FabricTelemetryInitializer, Microsoft.AI.ServiceFabric"/>
  </TelemetryInitializers>
  <TelemetryModules>
    <Add Type="Microsoft.ApplicationInsights.ServiceFabric.Module.ServiceRemotingRequestTrackingTelemetryModule, Microsoft.AI.ServiceFabric.Native"/>
    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector"/>
  </TelemetryModules>
  <TelemetryProcessors>
    <Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector"/>
  </TelemetryProcessors>
</ApplicationInsights>

Program.cs-

using System;
using System.Diagnostics;
using System.Fabric;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ServiceFabric.Services.Runtime;

namespace ConfigUploadService
{
    internal static class Program
    {
        /// <summary>
        /// This is the entry point of the service host process.
        /// </summary>
        private static void Main()
        {
            try
            {
                // The ServiceManifest.XML file defines one or more service type names.
                // Registering a service maps a service type name to a .NET type.
                // When Service Fabric creates an instance of this service type,
                // an instance of the class is created in this host process.

                ServiceRuntime.RegisterServiceAsync("ConfigUploadServiceType",
                    context => new ConfigUploadService(context)).GetAwaiter().GetResult();

                ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(ConfigUploadService).Name);

                // Prevents this host process from terminating so services keep running.
                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
                throw;
            }
        }
    }
}

我错过了什么?

推荐答案

您使用的默认模板针对的是遥测事件,您的应用程序事件源事件对于App Insights监视器是未知的,因此您必须设置这些事件的管道以告知这些事件属于您的应用程序,并且您希望将它们记录在AppInsights上。

您可以在诊断窗口中看到它们,因为VS会在您调试应用程序时进行注册。

我假设您正在寻找的内容在此链接中描述: service-fabric-diagnostics-event-aggregation-eventflow

事件流将为您提供执行此操作的工具,其灵活性与您处理遥测事件时的灵活性相同。

这篇关于Azure服务结构应用程序日志未出现在应用程序洞察中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆