public void LogException(BaseException ex)
        {
            const string format         = "\r\n ********** Log (Thread:#{0}; Stamp:{1}) **********\r\nCode:{2}. Key:{3}\r\n{4}";
            var          nowStampString = DateTime.Now.ToLogStampString();
            string       threadId       = Thread.CurrentThread.ManagedThreadId.ToString("00000");

            LogError(String.Format(CultureInfo.InvariantCulture, format,
                                   threadId,
                                   nowStampString,
                                   (int)ex.ErrorCode,
                                   ex.Key.ToString(), FormatException(ex)));
            if (UseEventLog)
            {
                LogEvent(EventLogEntryType.Error, ex.Message, ex, ex.ReferenceData, (int)ex.ErrorCode);
            }
        }
 public void LogException(BaseException ex)
 {
     const string format = "\r\n ********** Log (Thread:#{0}; Stamp:{1}) **********\r\nCode:{2}. Key:{3}\r\n{4}";
     var nowStampString = DateTime.Now.ToLogStampString();
     string threadId = Thread.CurrentThread.ManagedThreadId.ToString("00000");
     LogError(String.Format(CultureInfo.InvariantCulture, format,
         threadId,
         nowStampString,
         (int)ex.ErrorCode,
         ex.Key.ToString(), FormatException(ex)));
     if (UseEventLog)
     {
         LogEvent(EventLogEntryType.Error, ex.Message, ex, ex.ReferenceData, (int)ex.ErrorCode);
     }
 }
        /// <summary>
        /// Formats the exception.
        /// </summary>
        /// <param name="ex">The ex.</param>
        /// <returns>System.String.</returns>
        private static string FormatException(BaseException ex)
        {
            StringBuilder exDetails = new StringBuilder();
            exDetails.AppendFormat(CultureInfo.InvariantCulture, "Exception Type: {0}\r\n", ex.GetType().ToString());

            exDetails.AppendFormat(CultureInfo.InvariantCulture, "\r\nException Message: {0}", ex.Message);
            exDetails.AppendFormat(CultureInfo.InvariantCulture, "\r\n\r\nSource: {0}", ex.Source);
            exDetails.AppendFormat(CultureInfo.InvariantCulture, "\r\nSite: {0}", ex.TargetSite);
            exDetails.AppendFormat(CultureInfo.InvariantCulture, "\r\nStackTrace: {0}\r\n", ex.StackTrace);
            exDetails.AppendFormat(CultureInfo.InvariantCulture, "\r\nData Reference: {0}\r\n", GenerateDataString(ex.ReferenceData));

            if (ex.InnerException != null)
            {
                BaseException innerException = ex.InnerException as BaseException;
                if (innerException != null)
                {
                    exDetails.AppendFormat(CultureInfo.InvariantCulture, "\r\n***** Inner Exception *****\r\n{0}", FormatException(innerException));
                }
                else
                {
                    exDetails.AppendFormat(CultureInfo.InvariantCulture, "\r\n***** Inner Exception *****\r\n{0}", FormatException(ex.InnerException));
                }
            }

            return exDetails.ToString();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ExceptionInfo"/> class.
 /// </summary>
 /// <param name="faultCode">The fault code.</param>
 /// <param name="message">The message.</param>
 public ExceptionInfo(BaseException.FaultCode faultCode, string message)
     : this()
 {
     Code = (int)faultCode;
     Message = message;
 }