我已升级到Azure SDK 2.5并使用EventSources
切换到语义记录。
日志记录在本地使用自定义EventListener
。
部署后,日志会写入存储表,但只会填充EventId
,Pid
,Tid
等,这些真正有趣的字段(消息,任务,关键字,操作码)留空。
诊断基础设施日志充满了关于ETW的错误,但我不知道该怎么做:
Failed to load backup EventSource manifest file C:\Resources\{13b7ec61-6424-d4d3-9972-a83e58d8d6bb}\directory\f71b19461fcf494d89d3717b3a13cadf. something.WorkerRole.DiagnosticStore\WAD0103\Configuration\EventSource_Manifest_fe06b63d-39aa-5419-0529-18c4dacf4f68_Ver_20.backup.xml;
EventSource events will be logged without a proper schema until provider sends the manifest packets
Load manifest file failed for C:\Resources\{13b7ec61-6424-d4d3-9972-a83e58d8d6bb}\directory\f71b19461fcf494d89d3717b3a13cadf.something. WorkerRole. DiagnosticStore\WAD0103\Configuration\EventSource_Manifest_fe06b63d-39aa-5419-0529-18c4dacf4f68_Ver_20.xml
Failed to manage manifest version for file C:\Resources\{13b7ec61-6424-d4d3-9972-a83e58d8d6bb}\directory\f71b19461fcf494d89d3717b3a13cadf. something. WorkerRole.DiagnosticStore\WAD0103\Configuration\EventSource_Manifest_fe06b63d-39aa-5419-0529-18c4dacf4f68_Pid_3436.xml
Failed to process EventSource manifest event GUID:fe06b63d-39aa-5419-0529-18c4dacf4f68, event id:0xFFFE
Change in the number of events lost since the last sample: EventsCaptured=2 EventsLogged=1 EventsLost=0
我不使用清单文件并通过类/属性名称指定EventSource
:
<EtwEventSourceProviderConfiguration scheduledTransferPeriod="PT3M" scheduledTransferLogLevelFilter="Information" provider="something.Core">
<DefaultEvents eventDestination="CoreEvents" />
</EtwEventSourceProviderConfiguration>
我必须遗漏一些东西,但我不知道是什么。
其余诊断服务全部有效(基础架构日志,性能计数器等)。
正在记录的EventId
是正确的,但缺少日志的所有重要信息,我想是因为配置不完整?
修改:这是我的EventSource
代码。我不会发布整个事情,因为它非常大。我使用另一种类型来调用EventSource方法并处理参数的格式化(如果在该级别启用了源)。大多数方法参数都是string
类型,没有传递任何对象或其他复杂类型(处理另一种类型)。
[EventSource(Name = "something.Core")]
public sealed class CoreEventSource : EventSource {
private static readonly CoreEventSource SoleInstance = new CoreEventSource();
static CoreEventSource() {}
private CoreEventSource() {}
public static CoreEventSource Instance {
get { return SoleInstance; }
}
public static EventKeywords AllKeywords = (EventKeywords)(-1);
public class Keywords {
public const EventKeywords None = (EventKeywords)(1 << 1);
public const EventKeywords Infrastructure = (EventKeywords)(1 << 2);
[...]
}
public class Tasks {
public const EventTask None = EventTask.None;
// generic operations
public const EventTask Create = (EventTask)11;
public const EventTask Update = (EventTask)12;
public const EventTask Delete = (EventTask)13;
public const EventTask Get = (EventTask)14;
public const EventTask Put = (EventTask)15;
public const EventTask Remove = (EventTask)16;
public const EventTask Process = (EventTask)17;
}
[Event(1, Message = "Initialization of {0} failed: {1}.", Level = EventLevel.Critical, Keywords = Keywords.Infrastructure)]
public void CriticalInitializationFailure(string component, string details, string exception) {
this.WriteEvent(1, component, details, exception);
}
[Event(2, Message = "[Role '{0}'] Startup: {1}", Level = EventLevel.Informational, Keywords = Keywords.Infrastructure)]
public void RoleStartup(string roleName, string message) {
this.WriteEvent(2, roleName, message);
}
[Event(3, Message = "[Role '{0}'] Stop failed: {1}.", Level = EventLevel.Error, Keywords = Keywords.Infrastructure)]
public void RoleStopFailed(string roleName, string details, string exception) {
this.WriteEvent(3, roleName, details, exception);
}
[Event(4, Message = "An unhandled exception occurred.", Level = EventLevel.Critical, Keywords = Keywords.Infrastructure)]
public void UnhandledException(string exception) {
this.WriteEvent(4, exception);
}
[Event(5, Message = "An unobserved exception occurred in a faulted task.", Level = EventLevel.Critical, Keywords = Keywords.Infrastructure)]
public void UnobservedTaskException(string exception) {
this.WriteEvent(5, exception);
}
[...]
}
答案 0 :(得分:3)
事实证明我的EventSource
存在很多问题。对于使用ETW的任何人,我建议使用来自NuGet的Microsoft TraceEvent Library,即使您使用System.Diagnostics.Tracing
,因为它附带了一个可以验证您的EventSource
代码的工具并通知你有关问题的信息。
我必须解决以下问题:
EventSource
名称不得包含句点.
EventSource
None
字段
希望这对遇到类似问题的人有用。
答案 1 :(得分:0)
应该注意的另一件事(修复了我们的案例) - EventSources应该只有一个Name或一个Guid,而不是两者。
在我们的案例中,两者都造成了 - EtwEventSourceProvider不记录任何内容 - EtwEventManifestProvider以与您描述的方式相同的方式记录,具有空数据点。