首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Azure service fabric应用程序日志未出现在应用程序洞察力中

Azure service fabric应用程序日志未出现在应用程序洞察力中
EN

Stack Overflow用户
提问于 2018-05-14 03:50:32
回答 1查看 1.2K关注 0票数 1

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

例如日志行-

代码语言:javascript
复制
ServiceEventSource.Current.ServiceMessage(this.Context, "Config deployment is disabled.");

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

ApplicationInsights.config -

代码语言:javascript
复制
<?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-

代码语言:javascript
复制
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;
            }
        }
    }
}

我错过了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-05-14 08:59:04

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

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

我假设您所要寻找的内容在以下链接中描述:service-fabric-diagnostics-event-aggregation-eventflow

事件流将为您提供工具,使您具有与遥测事件相同的灵活性。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50322861

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档