Question

Simple Windows console app:

using System.Diagnostics;

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            EventLog.WriteEntry("Application", "HELLO!", EventLogEntryType.Error, 22);
        }
    }
}

When I run this (as a local admin) on Server 2012, it works - except the message is not displayed when I view this event in Server Manager. Why is the message ("HELLO!") not showing up?

EDIT: Screenshot of Server Manager: enter image description here

Was it helpful?

Solution

Figured out the problem - the first arg of EventLog is not which log to write the info to (thought I saw that was the case in some doc), but the name of source of the message which should be shown in the log. For whatever reason, it fails when that source name is "Application". Changing it to something more relevant makes it work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top