CodeKeep C# Feed Giugno 16th, 2008
CodeKeep C# Feed Giugno 16th, 2008
->
Description: catch block that writes to the event log if the event log source exists.
Link: http://www.codekeep.net/snippets/d78d6529-4ae6-4979-bb36-97dec24c6958.aspx
catch (Exception ex)
{
if (EventLog.SourceExists(ConfigurationManager.AppSettings["EventLogSource"]))
{
List<string> exVarList = new List<string>();
exVarList.Add(ex.Source + ":");
StringBuilder sb = new StringBuilder();
sb.AppendLine("Exception:==================");
sb.AppendLine(ex.ToString());
sb.AppendLine("Variable List:==============");
foreach (string s in exVarList)
{
sb.AppendLine(s);
}
EventLog eventLog = new EventLog(ConfigurationManager.AppSettings["EventLogName"],
ConfigurationManager.AppSettings["EventLogMachine"],
ConfigurationManager.AppSettings["EventLogSource"]);
eventLog.WriteEntry(sb.ToString(), EventLogEntryType.Warning);
}
}

CodeKeep C# Feed Giugno 16th, 2008
Description: catch block that writes to the event log if the event log source exists.
Link: http://www.codekeep.net/snippets/d78d6529-4ae6-4979-bb36-97dec24c6958.aspx
catch (Exception ex)
{
if (EventLog.SourceExists(ConfigurationManager.AppSettings["EventLogSource"]))
{
List<string> exVarList = new List<string>();
exVarList.Add(ex.Source + ":");
StringBuilder sb = new StringBuilder();
sb.AppendLine("Exception:==================");
sb.AppendLine(ex.ToString());
sb.AppendLine("Variable List:==============");
foreach (string s in exVarList)
{
sb.AppendLine(s);
}
EventLog eventLog = new EventLog(ConfigurationManager.AppSettings["EventLogName"],
ConfigurationManager.AppSettings["EventLogMachine"],
ConfigurationManager.AppSettings["EventLogSource"]);
eventLog.WriteEntry(sb.ToString(), EventLogEntryType.Warning);
}
}

CodeKeep C# Feed Giugno 16th, 2008
Description: catch block that writes to the event log if the event log source exists.
Link: http://www.codekeep.net/snippets/d78d6529-4ae6-4979-bb36-97dec24c6958.aspx
catch (Exception ex)
{
if (EventLog.SourceExists(ConfigurationManager.AppSettings["EventLogSource"]))
{
List<string> exVarList = new List<string>();
exVarList.Add(ex.Source + ":");
StringBuilder sb = new StringBuilder();
sb.AppendLine("Exception:==================");
sb.AppendLine(ex.ToString());
sb.AppendLine("Variable List:==============");
foreach (string s in exVarList)
{
sb.AppendLine(s);
}
EventLog eventLog = new EventLog(ConfigurationManager.AppSettings["EventLogName"],
ConfigurationManager.AppSettings["EventLogMachine"],
ConfigurationManager.AppSettings["EventLogSource"]);
eventLog.WriteEntry(sb.ToString(), EventLogEntryType.Warning);
}
}
