• R/O
  • SSH
  • HTTPS

ewatch: Commit


Commit MetaInfo

Revision94 (tree)
Time2018-08-03 00:11:24
Authorbananajinn

Log Message

イベントログの FormatDescription で System.Diagnostics.Eventing.Reader.EventLogException が発生するとサービスが終了してしまうのを catch して回避する

Change Summary

Incremental Difference

--- trunk/EWatch/EWatch/Watchers/EventLogWatcher.cs (revision 93)
+++ trunk/EWatch/EWatch/Watchers/EventLogWatcher.cs (revision 94)
@@ -85,10 +85,21 @@
8585 Source = rec.ProviderName,
8686 Level = level,
8787 TimeStamp = rec.TimeCreated,
88- Message = rec.FormatDescription(),
88+ Message = GetMessage(rec),
8989 });
9090 }
9191 }
9292 }
93+
94+ private string GetMessage(EventRecord rec)
95+ {
96+ try {
97+ return rec.FormatDescription;
98+ }
99+ catch(Exception ex) {
100+ log.Error("format error", ex);
101+ return "---";
102+ }
103+ }
93104 }
94105 }
Show on old repository browser