4

我正在使用 Windows azure 项目开发 Enterprise library 6。基于快速启动应用程序,我们可以将消息、事件记录到 XML 文件或 sql 服务器。以下代码在示例应用程序中执行此操作。

            this.fileListener = FlatFileLog.CreateListener("aExpense.DataAccess.log", formatter: new XmlEventTextFormatter(EventTextFormatting.Indented), isAsync: true);
            fileListener.EnableEvents(AExpenseEvents.Log, EventLevel.LogAlways, AExpenseEvents.Keywords.DataAccess);

            //Log to Rolling file informational UI events only
            this.rollingfileListener = RollingFlatFileLog.CreateListener("aExpense.UserInterface.log", rollSizeKB: 10, timestampPattern: "yyyy", rollFileExistsBehavior: RollFileExistsBehavior.Increment, rollInterval: RollInterval.Day, formatter: new JsonEventTextFormatter(EventTextFormatting.Indented), isAsync: true);
            rollingfileListener.EnableEvents(AExpenseEvents.Log, EventLevel.Informational, AExpenseEvents.Keywords.UserInterface);                

            // Log all events to DB 
            this.dbListener = SqlDatabaseLog.CreateListener("aExpense", WebConfigurationManager.ConnectionStrings["Tracing"].ConnectionString, bufferingInterval: TimeSpan.FromSeconds(3), bufferingCount:10);
            dbListener.EnableEvents(AExpenseEvents.Log, EventLevel.LogAlways, Keywords.All); 

但我需要将所有这些事件和异常记录到 Azure 表存储。Enterprise Library 6 可以支持吗?怎么做 ?

4

1 回答 1

4

根据代码示例,您似乎正在使用语义日志记录块。语义记录应用程序块有一个 Windows Azure 接收器,它将记录到表存储。

this.azuretableListener = WindowsAzureTableLog.CreateListener(
    RoleEnvironment.CurrentRoleInstance.Id, 
    RoleEnvironment.GetConfigurationSettingValue("ConnectionString"));

azuretableListener.EnableEvents(AExpenseEvents.Log, EventLevel.LogAlways, Keywords.All);

默认表名是“SLABLogsTable”,但您可以指定其他名称。

于 2013-07-03T12:51:20.020 回答