Changeset 5593 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/Logger.cs
- Timestamp:
- 03/02/11 15:23:59 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Common/3.4/Logger.cs
r5511 r5593 1 1 using System; 2 2 using System.Diagnostics; 3 using System.Security; 4 using System.Threading; 3 5 4 6 namespace HeuristicLab.Services.Hive.Common { … … 17 19 private EventLog log; 18 20 21 /// <summary> 22 /// Creating an EventSource requires certain permissions, which by default a IIS AppPool user does not have. 23 /// In this case just ignore security exceptions. 24 /// In order to make this work, the eventsource needs to be created manually 25 /// </summary> 19 26 public Logger(string name, string source) { 20 //if (!EventLog.SourceExists(name)) { 21 // EventLog.CreateEventSource(source, name); 22 //} 23 //log = new EventLog(name); 24 //log.Source = source; 27 try { 28 if (!EventLog.SourceExists(source)) { 29 EventLog.CreateEventSource(source, name); 30 } 31 log = new EventLog(name); 32 log.Source = source; 33 } 34 catch (SecurityException) { } 25 35 } 26 36 27 37 public void Log(string message) { 28 //log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Information); 38 try { 39 log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Information); 40 } 41 catch (SecurityException) { } 29 42 } 30 43 31 44 public void Error(Exception e) { 32 //log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", e.Message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Error); 45 try { 46 log.WriteEntry(string.Format("{0} (AppDomain: {1}, Thread: {2})", e.Message, AppDomain.CurrentDomain.Id, Thread.CurrentThread.ManagedThreadId), EventLogEntryType.Error); 47 } 48 catch (SecurityException) { } 33 49 } 34 50 }
Note: See TracChangeset
for help on using the changeset viewer.