/// <summary>
 /// Adds the exception info.
 /// </summary>
 /// <param name="log">The log entry.</param>
 /// <param name="exception">The exception.</param>
 /// <returns></returns>
 protected virtual void AddExceptionInfo(LogEntry log, Exception exception)
 {
     if (exception != null && settings.exceptionFormat != null)
     {
         string errorMessage = settings.exceptionFormat
             .Replace("$(exception.message)", exception.Message)
             .Replace("$(exception.source)", exception.Source)
             .Replace("$(exception.targetsite)", (exception.TargetSite==null)?string.Empty:exception.TargetSite.ToString())
             .Replace("$(exception.stacktrace)", exception.StackTrace)
             ;
         //                StringBuilder sb = new StringBuilder(128);
         //                sb.Append("Exception[ ");
         //                sb.Append("message = ").Append(exception.Message).Append(separator);
         //                sb.Append("source = ").Append(exception.Source).Append(separator);
         //                sb.Append("targetsite = ").Append(exception.TargetSite).Append(separator);
         //                sb.Append("stacktrace = ").Append(exception.StackTrace).Append("]");
         //                return sb.ToString();
         log.AddErrorMessage(errorMessage);
     }
 }
        public void Log(LoggingData loggingData)
        {
            var logEntry = new LogEntry();

            logEntry.Message = loggingData.Message;
            logEntry.AppDomainName = loggingData.Domain;
            logEntry.AddErrorMessage(loggingData.ExceptionString);
            logEntry.Categories = new string[] { loggingData.LoggerName };

            TraceEventType eventType;

            if (!s_EventTypeDict.TryGetValue(loggingData.Level, out eventType))
                eventType = TraceEventType.Information;

            logEntry.Severity = eventType;

            logEntry.ManagedThreadName = loggingData.ThreadName;
            logEntry.TimeStamp = loggingData.TimeStamp;

            m_LogWriter.Write(logEntry);
        }