Example #1
0
 /// <summary>
 /// Logs an exception to the event log.
 /// </summary>
 /// <param name="e">The exception to log.</param>
 /// <param name="log">The event log to log the exception to.</param>
 /// <returns>True if the exception was logged successfully. False otherwise.</returns>
 private static bool LogException(Exception e, IEventLog log)
 {
     if (log != null)
     {
         log.Log(new Event(typeof(ConfigurationItem).FullName, DateTime.Now, Event.SeverityLevels.Error, e.GetType().FullName,
                           "Description:\n" +
                           e.Message + "\n" +
                           "Stack Trace:\n" +
                           e.StackTrace));
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #2
0
 /// <summary>
 /// Logs an exception to the event log.
 /// </summary>
 /// <param name="e">The exception to log.</param>
 /// <param name="log">The event log to log the exception to.</param>
 /// <returns>True if the exception was logged successfully. False otherwise.</returns>
 private static bool LogException(Exception e, IEventLog log)
 {
     if (log != null)
     {
         log.Log(new Event(typeof(ConfigurationItem).FullName, DateTime.Now, Event.SeverityLevels.Error, e.GetType().FullName,
             "Description:\n" +
             e.Message + "\n" +
             "Stack Trace:\n" +
             e.StackTrace));
         return true;
     }
     else
     {
         return false;
     }
 }
Example #3
0
 /// <summary>
 /// Logs the information.
 /// </summary>
 /// <param name="eventLog">The event log.</param>
 /// <param name="format">The format.</param>
 /// <param name="arguments">The arguments.</param>
 public static void LogInformation(this IEventLog eventLog, string format, params object[] arguments)
 {
     eventLog.Log(EventLogType.Information, string.Format(format, arguments), null);
 }
Example #4
0
 /// <summary>
 /// Logs the verbose.
 /// </summary>
 /// <param name="eventLog">The event log.</param>
 /// <param name="format">The format.</param>
 /// <param name="arguments">The arguments.</param>
 public static void LogVerbose(this IEventLog eventLog, string format, params object[] arguments)
 {
     eventLog.Log(EventLogType.Verbose, string.Format(format, arguments), null);
 }
Example #5
0
 /// <summary>
 /// Logs the warning.
 /// </summary>
 /// <param name="eventLog">The event log.</param>
 /// <param name="e">The exception.</param>
 public static void LogWarning(this IEventLog eventLog, Exception e)
 {
     eventLog.Log(EventLogType.Warning, string.Format("Exception: {0}", e.Message), e);
 }