1catch (Exception ex)
2 {
3 if (EventLog.SourceExists(ConfigurationManager.AppSettings["EventLogSource"]))
4 {
5 List<string> exVarList = new List<string>();
6 exVarList.Add(ex.Source + ":");
7 StringBuilder sb = new StringBuilder();
8 sb.AppendLine("Exception:==================");
9 sb.AppendLine(ex.ToString());
10 sb.AppendLine("Variable List:==============");
11 foreach (string s in exVarList)
12 {
13 sb.AppendLine(s);
14 }
15 EventLog eventLog = new EventLog(ConfigurationManager.AppSettings["EventLogName"],
16 ConfigurationManager.AppSettings["EventLogMachine"],
17 ConfigurationManager.AppSettings["EventLogSource"]);
18
19 eventLog.WriteEntry(sb.ToString(), EventLogEntryType.Warning);
20 }
21 }