Azure service fabric Azure service fabric应用程序日志未出现在app insights中
我正在使用VS模板附带的ServiceEventSource实现来记录消息。它显示在诊断事件查看器中,但不显示在已配置的application insights实例中。 我在application insights实例中获得了其他平台事件,但我的应用程序日志记录没有 示例日志行-Azure service fabric Azure service fabric应用程序日志未出现在app insights中,azure-service-fabric,azure-application-insights,Azure Service Fabric,Azure Application Insights,我正在使用VS模板附带的ServiceEventSource实现来记录消息。它显示在诊断事件查看器中,但不显示在已配置的application insights实例中。 我在application insights实例中获得了其他平台事件,但我的应用程序日志记录没有 示例日志行- ServiceEventSource.Current.ServiceMessage(this.Context, "Config deployment is disabled."); 除了使用VisualStudio上
ServiceEventSource.Current.ServiceMessage(this.Context, "Config deployment is disabled.");
除了使用VisualStudio上下文菜单配置应用程序洞察之外,我没有做过其他任何事情。在创建服务结构集群时,我也提供了正确的检测键
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>
ac5a18e4-3750-46b4-ac10-2a887915b163
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;
}
}
}
}
使用系统;
使用系统诊断;
使用系统、织物;
使用系统线程;
使用System.Threading.Tasks;
使用Microsoft.ServiceFabric.Services.Runtime;
命名空间配置上载服务
{
内部静态类程序
{
///
///这是服务主机进程的入口点。
///
私有静态void Main()
{
尝试
{
//ServiceManifest.XML文件定义一个或多个服务类型名称。
//注册服务将服务类型名称映射到.NET类型。
//当服务结构创建此服务类型的实例时,
//该类的实例在此主机进程中创建。
ServiceRuntime.RegisterServiceAsync(“ConfigUploadServiceType”,
context=>newconfiguploadservice(context)).GetAwaiter().GetResult();
ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id,typeof(ConfigUploadService).Name);
//阻止此主机进程终止,以使服务保持运行。
Thread.Sleep(Timeout.Infinite);
}
捕获(例外e)
{
ServiceEventSource.Current.ServiceHostInitialization失败(例如ToString());
投掷;
}
}
}
}
我遗漏了什么?您使用的默认模板针对遥测事件,App Insights monitor不知道您的应用程序事件源事件,因此您必须为这些事件设置管道,以告知这些事件属于您的应用程序,并且您要将它们记录在AppInsights上 您可以在诊断窗口中看到它们,因为VS会在调试应用程序时注册 我假设您要查找的内容在以下链接中描述: 事件流将为您提供与遥测事件相同的灵活性的工具