예약 된 작업을 통해 실행되는 콘솔 응용 프로그램이 있으며이를 수행하려면 catch 블록의 이벤트 로그에 쓰기 권한을 부여해야합니다. 사용해 보았습니다.이벤트 로그에 쓰기 Windows 예약 된 작업
EventLog.WriteEntry("My App Name","Error Message - " ex.ToString());
그러나 어떤 이유로 오류를 기록하지 않습니다. 내가 잘못하고 있니?
감사
예약 된 작업을 통해 실행되는 콘솔 응용 프로그램이 있으며이를 수행하려면 catch 블록의 이벤트 로그에 쓰기 권한을 부여해야합니다. 사용해 보았습니다.이벤트 로그에 쓰기 Windows 예약 된 작업
EventLog.WriteEntry("My App Name","Error Message - " ex.ToString());
그러나 어떤 이유로 오류를 기록하지 않습니다. 내가 잘못하고 있니?
감사
당신은, 반드시 이벤트 소스가 존재하기 위해 예를 들어 필요합니다
if (!EventLog.SourceExists("MySource"))
EventLog.CreateEventSource("MySource","Application");
이 코드는 C#에서 MSDN 웹 사이트에서이다, 내가 당신을 도와 바랍니다.
using System;
using System.Diagnostics;
using System.Threading;
class MySample{
public static void Main(){
// Create the source, if it does not already exist.
if(!EventLog.SourceExists("MySource")){
EventLog.CreateEventSource("MySource", "MyNewLog");
Console.WriteLine("CreatingEventSource");
}
// Create an EventLog instance and assign its source.
EventLog myLog = new EventLog();
myLog.Source = "MySource";
// Write an informational entry to the event log.
myLog.WriteEntry("Writing to event log.");
}
}
한 가지를 참조하십시오으로 EventLog.CreateEventSource를 호출 약간의 지연이 종종 있다는 것입니다 생성 된 EventSource를 생성 직후에 액세스하려고 할 때이를 인식해야합니다.