MVC Azure Webapp的语义日志记录(SLAB)

时间:2015-06-22 13:59:22

标签: azure web-applications slab

我正在尝试为我的Azure Web应用程序实施SLAB(正在处理中),我的列表工具是Azure表存储(表格连接字符串), 面临的问题是 - “EventSource.IsEnabled()=总是返回false” (我使用IIS Express从VS2013运行应用程序)

我的代码

---- global.asax中

var listener2 = new ObservableEventListener();
listener2.EnableEvents(SBEvents.Log, EventLevel.Verbose,Keywords.All);
listener2.LogToWindowsAzureTable(“sdf”, “DefaultEndpointsProtocol=https;AccountName=********;AccountKey=****************);

----事件来源

Public class SBEvents :EventSource {
public class keywords{...}
public class Tasks {..}

private static readonly Lazy Instance = new Lazy(() => new SBEvents());
public static SBEvents Log { get { return Instance.Value; } }

[Event(102, Message = “Bike started with Bike ID :{0}”, Keywords =    Keywords.Application, Level = EventLevel.Informational)]
public void BikeStarted(String BikeID){
if (this.IsEnabled()) //// = always returns false
this.WriteEvent(102,BikeID);

1 个答案:

答案 0 :(得分:0)

看起来“Azure Web Apps”无法收听ETW事件。

https://azure.microsoft.com/en-in/documentation/articles/choose-web-site-cloud-service-vm/

Azure上的Web应用程序无法使用的诊断日志记录和跟踪区域是Windows ETW事件和常见的Windows事件日志(例如,系统,应用程序和安全事件日志)。由于ETW跟踪信息可能在整个机器范围内可见(使用正确的ACL),因此阻止了对ETW事件的读写访问。开发人员可能会注意到读取和写入ETW事件的API调用以及常见的Windows事件日志似乎都有效,但这是因为WEb Apps正在“伪造”调用以使它们看起来成功。实际上,Web应用程序代码无法访问此事件数据

由于