문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top