RwEventLog를 이용하여, Windows Event Log를 쉽게 사용할 수 있는 Utility Class 입니다.
 public void FindEntryByEntryTypeTest()
 {
     using (var eventLog = EventLogTool.GetEventLog(EventLogName)) {
         DisplayEntries(EventLogTool.FindEntryByEntryType(eventLog, EventLogEntryType.Error),
                        "FindEntryByEntryType");
     }
 }
 public void FindEntryByGeneratedTimeTest()
 {
     using (var eventLog = EventLogTool.GetEventLog(EventLogName)) {
         DisplayEntries(EventLogTool.FindEntryByGeneratedTime(eventLog, DateTime.Now.AddMinutes(-5), false),
                        "FindEntryByGeneratedTime");
     }
 }
 public void FindEntryBySourceTest()
 {
     using (var eventLog = EventLogTool.GetEventLog(EventLogName)) {
         var entries = EventLogTool.FindEntryBySource(eventLog, EventLogSource, true);
         DisplayEntries(entries, "FindLogEntryBySource");
     }
 }
        public void WriteEntryTest()
        {
            EventLogTool.WriteEntry(EventLogName,
                                    EventLogSource,
                                    "EventLog Information Message Test",
                                    EventLogEntryType.Information);

            EventLogTool.WriteEntry(EventLogName,
                                    EventLogSource,
                                    "EventLog Error Message Test",
                                    EventLogEntryType.Error);
        }
示例#5
0
        /// <summary>
        /// RwEventLog 생성자
        /// </summary>
        /// <param name="logName">ex: Application, Security, System 같은 로그 이름</param>
        /// <param name="machineName">Computer machine name (ex '.')</param>
        /// <param name="source">event source (일반적으로 Assembly 명을 사용한다)</param>
        public EventLogger(string logName, string machineName, string source)
        {
            if (IsDebugEnabled)
            {
                log.Debug("Create EventLogger with logName=[{0}], machineName=[{1}], source=[{2}]", logName, machineName, source);
            }

            LogName     = logName.AsText().Trim();
            MachineName = machineName;

            if (source.IsEmpty())
            {
                source = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Assembly.GetName().Name;
            }

            Source = source;

            _eventLog = EventLogTool.GetEventLog(LogName, Source, MachineName);

            IsSystemDefault = SystemDefaultLogNames.Any(name => name.Compare(LogName, true) == 0);
        }
示例#6
0
 /// <summary>
 /// 지정된 <c>EventLogEntryType</c>(수준)과 같은 <c>EventLogEntry</c>를 검색한다.
 /// </summary>
 /// <param name="entryType">검색할 <c>EventLogEntryType</c>(수준)의 값</param>
 /// <returns>찾은 <c>EventLogEntry</c>의 컬렉션</returns>
 public IEnumerable <EventLogEntry> FindEntryByEntryType(EventLogEntryType entryType)
 {
     return(EventLogTool.FindEntryByEntryType(Log, entryType));
 }
示例#7
0
 /// <summary>
 /// EventLog 중 생성일 전/후의 Entry를 검색
 /// </summary>
 /// <param name="generatedTime">검색 기준이 되는 생성시간</param>
 /// <param name="isBefore">생성시간 전, 후를 나눔</param>
 /// <returns></returns>
 public IEnumerable <EventLogEntry> FindEntryByTime(DateTime generatedTime, bool isBefore)
 {
     return(EventLogTool.FindEntryByGeneratedTime(Log, generatedTime, isBefore));
 }