Пример #1
0
 private static void LogException(Exception e, string sourceMethod, LogTypeEnum type, string logFile, string additionalMessage = null)
 {
     if (!String.IsNullOrEmpty(logFile))
     {
         Utility.WriteToLogFile(logFile, string.Format("[{0}][{1}][{2}][{3}][{4}][{5}][{6}]"
                                                       , DateTime.Now.ToString()
                                                       , type
                                                       , sourceMethod
                                                       , "nouser"
                                                       , System.Environment.MachineName
                                                       , e.Message
                                                       , additionalMessage));
     }
     else
     {
         using (var logClient = new LoggingService.BILoggerServiceClient())
         {
             logClient.HandleBIExceptionAsync(e.ConvertToBIException(LogActionEnum.LogAndEmail
                                                                     , type
                                                                     , sourceMethod + " Error"
                                                                     , sourceMethod
                                                                     , "nouser"
                                                                     , System.Environment.MachineName
                                                                     , additionalMessage));
         }
     }
 }
Пример #2
0
 /// <summary>
 /// Log an error to the service.
 /// This method forces the error to be logged to the BI Logging Service even if a log file is supplied in the config
 /// </summary>
 /// <param name="e"></param>
 /// <param name="method">Method where the exception occured</param>
 /// <param name="applicationName">Application Name that matches the logging database</param>
 /// <param name="additionalMessage"></param>
 public static void LogError(Exception e, string method, string applicationName, string additionalMessage = null)
 {
     using (var logClient = new LoggingService.BILoggerServiceClient())
     {
         logClient.HandleBIExceptionAsync(e.ConvertToBIException(LogActionEnum.LogAndEmail
                                                                 , LogTypeEnum.Error
                                                                 , method + " Error"
                                                                 , method
                                                                 , "nouser"
                                                                 , System.Environment.MachineName
                                                                 , applicationName
                                                                 , additionalMessage));
     }
 }