My website, written in ASP.NET and i used EventLog to write logs into the event viewer. It is already been running in the production (OS: Windows Server 2012 R2) and no problems encountered upon logging some errors. I am now planning to migrate the server to Azure - App Services. I wonder if my code in logging the errors would still work after moving to Azure - App Services?? If yes then how do i view the error that have been logged by my website?? I cannot see Event Viewer in the Azure - App Services. If no then what is the simplest and fastest alternate way to replace my code in logging the errors??
Here is my code:
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");
}
}