protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
 {
     StackFrameItem[] stackFrames = loggingEvent.LocationInformation.StackFrames;
     if ((stackFrames == null) || (stackFrames.Length <= 0))
     {
         LogLog.Error(declaringType, "loggingEvent.LocationInformation.StackFrames was null or empty.");
     }
     else
     {
         int index = this.m_stackFrameLevel - 1;
         while (index >= 0)
         {
             if (index >= stackFrames.Length)
             {
                 index--;
                 continue;
             }
             StackFrameItem item = stackFrames[index];
             writer.Write("{0}.{1}", item.ClassName, this.GetMethodInformation(item.Method));
             if (index > 0)
             {
                 writer.Write(" > ");
             }
             index--;
         }
     }
 }
Beispiel #2
0
        protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
        {
            StackFrameItem[] stackframes = loggingEvent.LocationInformation.StackFrames;
            if ((stackframes == null) || (stackframes.Length <= 0))
            {
                LogLog.Error(declaringType, "loggingEvent.LocationInformation.StackFrames was null or empty.");
                return;
            }

            int stackFrameIndex = m_stackFrameLevel - 1;

            while (stackFrameIndex >= 0)
            {
                if (stackFrameIndex >= stackframes.Length)
                {
                    stackFrameIndex--;
                    continue;
                }

                StackFrameItem stackFrame = stackframes[stackFrameIndex];
                writer.Write("{0}.{1}", stackFrame.ClassName, GetMethodInformation(stackFrame.Method));
                if (stackFrameIndex > 0)
                {
                    // TODO: make this user settable?
                    writer.Write(" > ");
                }
                stackFrameIndex--;
            }
        }
        public AzureLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType)
        {
            Domain   = e.Domain;
            Identity = e.Identity;
            Level    = e.Level.ToString();
            var sb = new StringBuilder(e.Properties.Count);

            foreach (DictionaryEntry entry in e.Properties)
            {
                sb.AppendFormat("{0}:{1}", entry.Key, entry.Value);
                sb.AppendLine();
            }
            Properties     = sb.ToString();
            Message        = e.RenderedMessage + Environment.NewLine + e.GetExceptionString();
            ThreadName     = e.ThreadName;
            EventTimeStamp = e.TimeStamp;
            UserName       = e.UserName;
            Location       = e.LocationInformation.FullInfo;
            ClassName      = e.LocationInformation.ClassName;
            FileName       = e.LocationInformation.FileName;
            LineNumber     = e.LocationInformation.LineNumber;
            MethodName     = e.LocationInformation.MethodName;
            StackFrames    = new StackFrameItem[0];

            if (e.ExceptionObject != null)
            {
                Exception = e.ExceptionObject.ToString();
            }

            PartitionKey = e.MakePartitionKey(partitionKeyType);
            RowKey       = e.MakeRowKey();
        }