【发布时间】:2016-11-04 21:17:50
【问题描述】:
我的网站是用 ASP.NET 编写的,我使用 EventLog 将日志写入事件查看器。它已经在生产环境中运行(操作系统:Windows Server 2012 R2)并且在记录一些错误时没有遇到任何问题。我现在计划将服务器迁移到 Azure - 应用服务。我想知道在迁移到 Azure - 应用服务后,我记录错误的代码是否仍然有效?如果是,那么我如何查看我的网站记录的错误?我在 Azure - 应用服务中看不到事件查看器。如果不是,那么在记录错误时替换我的代码的最简单和最快的替代方法是什么??
这是我的代码:
public static void LogEventLog(string message, EventLogEntryType logType)
{
string source = AppConfig.ErrorEventViewerSource;
// Since we can't prevent the app from terminating, log this to the event log.
CreateEventSource(source);
// Create an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = source;
myLog.WriteEntry(message, logType);
}
public static void CreateEventSource(string source)
{
if (!EventLog.SourceExists(source))
{
EventLog.CreateEventSource(source, "Application");
}
}
【问题讨论】:
-
我也是 Azure 的新手,但据我了解,您需要将事件日志推送到诊断存储。请参阅此链接 - azure.microsoft.com/en-in/documentation/articles/…
标签: c# asp.net azure event-log event-viewer