When I write a log into windows event log, I get the event below, what\'s the root cause of this message, and how can I fix it? Many Thanks
The descri
Improving on the answer by @Alex, I suggest the following:
using (EventLog eventLog = new EventLog("Application"))
{
//You cannot be sure if the current identity has permissions to register the event source.
try
{
if (System.Web.HttpRuntime.AppDomainAppId != null)
{
eventLog.Source = System.Web.HttpRuntime.AppDomainAppId;
}
else
{
eventLog.Source = Process.GetCurrentProcess().ProcessName;
}
}
catch (SecurityException)
{
eventLog.Source = "Application";
}
eventLog.WriteEntry("Log message example", EventLogEntryType.Information, 1000);
}
It is important here not to specify category parameter. If you do, and this is the same for the .NET Runtime so-called magic, the
The description for Event ID <...> from source <...> cannot be found.
is going to appear.