■ EventLog 클래스 : 이벤트 로그 사용하기
------------------------------------------------------------------------------------------------------------------------
▶ Program.cs
using System.Diagnostics;
namespace TestProject { /// <summary> /// 프로그램 /// </summary> class Program { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary> /// 이벤트 로그 /// </summary> private static EventLog _eventLog;
/// <summary> /// 이벤트 소스명 /// </summary> private static string _eventSourceName = "TestSource";
/// <summary> /// 이벤트 로그명 /// </summary> private static string _eventLogName = "TestLog";
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method ////////////////////////////////////////////////////////////////////////////////////////// Static //////////////////////////////////////////////////////////////////////////////// Private
#region 프로그램 시작하기 - Main()
/// <summary> /// 프로그램 시작하기 /// </summary> private static void Main() { _eventLog = new EventLog();
if(!EventLog.SourceExists(_eventSourceName)) { EventLog.CreateEventSource(_eventSourceName, _eventLogName); }
_eventLog.Source = _eventSourceName; _eventLog.Log = _eventLogName;
// 이벤트 로그를 작성한다. _eventLog.WriteEntry("서비스를 시작합니다.");
// 이벤트 로그 폴더를 삭제한다. //EventLog.Delete(_eventLogName); }
#endregion } }
|
------------------------------------------------------------------------------------------------------------------------
'C# > Common' 카테고리의 다른 글
[C#/COMMON] AssemblyInstaller 클래스 : 윈도우즈 서비스 설치하기 (0) | 2016.06.12 |
---|---|
[C#/COMMON] ServiceController 클래스 : 윈도우즈 서비스 설치 여부 구하기 (0) | 2016.06.12 |
[C#/COMMON] ServiceController 클래스 : 윈도우즈 서비스 재시작하기 (0) | 2016.06.12 |
[C#/COMMON] ServiceController 클래스 : 윈도우즈 서비스 중단하기 (0) | 2016.06.12 |
[C#/COMMON] ServiceController 클래스 : 윈도우즈 서비스 시작하기 (0) | 2016.06.12 |
[C#/COMMON] EventLog 클래스 : 이벤트 로그 사용하기 (0) | 2016.06.12 |
[C#/COMMON] 쓰기/읽기 작업을 비동기 순차 처리하기 (0) | 2016.06.09 |
[C#/COMMON] Timer 클래스 사용하기 (0) | 2016.06.04 |
[C#/COMMON] ThreadPool 클래스 : RegisterWaitForSingleObject 메소드를 사용해 타임아웃 사용하기 (0) | 2016.06.04 |
[C#/COMMON] ThreadPool 클래스 : 취소 옵션 사용하기 (0) | 2016.06.04 |
[C#/COMMON] ThreadPool 클래스 : 비동기 호출하기 (0) | 2016.06.04 |
댓글을 달아 주세요