当前位置: 首页>>代码示例>>C#>>正文


C# LoggingEvent.GetExceptionString方法代码示例

本文整理汇总了C#中log4net.Core.LoggingEvent.GetExceptionString方法的典型用法代码示例。如果您正苦于以下问题:C# LoggingEvent.GetExceptionString方法的具体用法?C# LoggingEvent.GetExceptionString怎么用?C# LoggingEvent.GetExceptionString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在log4net.Core.LoggingEvent的用法示例。


在下文中一共展示了LoggingEvent.GetExceptionString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Append

        protected override void Append(LoggingEvent loggingEvent)
        {
            var entity = new LogEventAzure();

            try
            {
                entity.Message = loggingEvent.RenderedMessage;
                entity.Level = loggingEvent.Level.Name;
                entity.LoggerName = loggingEvent.LoggerName;
                entity.ThreadName = loggingEvent.ThreadName;
                entity.CorrelationId = null;
                entity.Value = 0.0;
                entity.UnitType = null;
                entity.Exception = null;

                if (!string.IsNullOrEmpty(loggingEvent.GetExceptionString()))
                    entity.Exception = loggingEvent.ExceptionObject.Message;

                if (loggingEvent.Properties["correlationId"] != null)
                    entity.CorrelationId = loggingEvent.Properties["correlationId"].ToString();

                if (loggingEvent.Properties["value"] != null)
                    entity.Value = Convert.ToDouble(loggingEvent.Properties["value"]);

                if (loggingEvent.Properties["unitType"] != null)
                    entity.UnitType = loggingEvent.Properties["unitType"].ToString();

                TableOperation insertOperation = TableOperation.Insert(entity);
                _table.Execute(insertOperation);
            }
            catch (Exception e)
            {
                ErrorHandler.Error("Could not write log entry", e);
            }
        }
开发者ID:proactima,项目名称:UXRiskLogger,代码行数:35,代码来源:TableStorageAppender.cs

示例2: AzureLoggingEventEntity

        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 = e.LocationInformation.StackFrames;

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

            PartitionKey = e.MakePartitionKey(partitionKeyType);
            RowKey = e.MakeRowKey();
        }
开发者ID:Thumann,项目名称:log4net.Azure,代码行数:31,代码来源:AzureLoggingEventEntity.cs

示例3: CreateLogData

		private XMS.Core.Logging.ServiceModel.Log CreateLogData(LoggingEvent logEvent)
		{
			XMS.Core.Logging.ServiceModel.Log log = new ServiceModel.Log();

			log.LogTime = logEvent.TimeStamp;
			log.Level = logEvent.Level.ToString();
			log.Message = logEvent.RenderedMessage;
			log.Exception = logEvent.GetExceptionString();
			log.Category = (string)logEvent.LookupProperty("Category");

			log.AppName = RunContext.AppName;
			log.AppVersion = RunContext.AppVersion;
			log.Machine = RunContext.Machine;

			log.UserId = logEvent.Properties.Contains("UserId") ? (int)logEvent.LookupProperty("UserId") : -1;
			log.UserIP = (string)logEvent.LookupProperty("UserIP");

			log.RawUrl = (string)logEvent.LookupProperty("RawUrl");


			log.AgentName = (string)logEvent.LookupProperty("AppAgent-Name");
			log.AgentVersion = (string)logEvent.LookupProperty("AppAgent-Version");
			log.AgentPlatform = (string)logEvent.LookupProperty("AppAgent-Platform");
			log.MobileDeviceManufacturer = (string)logEvent.LookupProperty("AppAgent-MobileDeviceManufacturer");
			log.MobileDeviceModel = (string)logEvent.LookupProperty("AppAgent-MobileDeviceModel");
			log.MobileDeviceId = (string)logEvent.LookupProperty("AppAgent-MobileDeviceId");

			return log;
		}
开发者ID:Kjubo,项目名称:xms.core,代码行数:29,代码来源:LogCenterAppender.cs

示例4: AzureDynamicLoggingEventEntity

        public AzureDynamicLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType)
        {
            this["Domain"] = e.Domain;
            this["Identity"] = e.Identity;
            this["Level"] = e.Level.ToString();
            this["LoggerName"] = e.LoggerName;
            this["Message"] = e.RenderedMessage + Environment.NewLine + e.GetExceptionString();
            this["EventTimeStamp"] = e.TimeStamp;
            this["ThreadName"] = e.ThreadName;
            this["UserName"] = e.UserName;
            this["Location"] = e.LocationInformation.FullInfo;

            if (e.ExceptionObject != null)
            {
                this["Exception"] = e.ExceptionObject.ToString();
            }
            
            foreach (DictionaryEntry entry in e.Properties)
            {
                var key = entry.Key.ToString()
                    .Replace(":", "_")
                    .Replace("@", "_")
                    .Replace(".", "_");
                this[key] = entry.Value;
            }

            Timestamp = e.TimeStamp;
            PartitionKey = e.MakePartitionKey(partitionKeyType);
            RowKey = e.MakeRowKey();
        }
开发者ID:Thumann,项目名称:log4net.Azure,代码行数:30,代码来源:AzureDynamicLoggingEventEntity.cs

示例5: GetXmlString

        internal static string GetXmlString(LoggingEvent loggingEvent)
        {
            var xmlMessage = new XElement(
                "LogEntry",
                new XElement("UserName", loggingEvent.UserName),
                new XElement("TimeStamp",
                             loggingEvent.TimeStamp.ToString(CultureInfo.InvariantCulture)),
                new XElement("ThreadName", loggingEvent.ThreadName),
                new XElement("LoggerName", loggingEvent.LoggerName),
                new XElement("Level", loggingEvent.Level.ToString()),
                new XElement("Identity", loggingEvent.Identity),
                new XElement("Domain", loggingEvent.Domain),
                new XElement("CreatedOn", DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)),
                new XElement("RenderedMessage", loggingEvent.RenderedMessage)
                );

            string exceptionStr = loggingEvent.GetExceptionString();

            if (!string.IsNullOrEmpty(exceptionStr))
            {
                xmlMessage.Add(new XElement("Exception", exceptionStr));
            }

            return xmlMessage.ToString();
        }
开发者ID:EdsonF,项目名称:log4net.aws,代码行数:25,代码来源:Utility.cs

示例6: Convert

		/// <summary>
		/// Write the exception text to the output
		/// </summary>
		/// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
		/// <param name="loggingEvent">the event being logged</param>
		/// <remarks>
		/// <para>
		/// If an exception object is stored in the logging event
		/// it will be rendered into the pattern output with a
		/// trailing newline.
		/// </para>
		/// <para>
		/// If there is no exception then nothing will be output
		/// and no trailing newline will be appended.
		/// It is typical to put a newline before the exception
		/// and to have the exception as the last data in the pattern.
		/// </para>
		/// </remarks>
		override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
		{
			string exceptionString = loggingEvent.GetExceptionString();
			if (exceptionString != null && exceptionString.Length > 0) 
			{
				writer.WriteLine(exceptionString);
			}
		}
开发者ID:kevinswarner,项目名称:Hover_OLD,代码行数:26,代码来源:ExceptionPatternConverter.cs

示例7: FormatSubject

        /// <summary>
        /// Formats email's subject using <see cref="SubjectLayout"/>.
        /// 
        /// <see cref="AppenderSkeleton.RenderLoggingEvent(TextWriter, log4net.Core.LoggingEvent)"/>
        /// </summary>
        /// <param name="loggingEvent"></param>
        protected void FormatSubject(LoggingEvent loggingEvent)
        {
            var layout = SubjectLayout;

            if (layout == null)
            {
                LogLog.Warn("SmtpAppender: No subjectLayout configured for appender [" + Name + "]");
                return;
            }

            var writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);

            if (layout.IgnoresException)
            {
                string exceptionStr = loggingEvent.GetExceptionString();
                if (!string.IsNullOrEmpty(exceptionStr))
                {
                    // render the event and the exception
                    layout.Format(writer, loggingEvent);
                    writer.WriteLine(exceptionStr);
                }
                else
                {
                    // there is no exception to render
                    layout.Format(writer, loggingEvent);
                }
            }
            else
            {
                // The layout will render the exception
                layout.Format(writer, loggingEvent);
            }

            string subject = writer.ToString();

            //  Take first line only (Subject may not contain any control chars)
            var idx = subject.IndexOf("\r\n");
            if (idx != -1)
            {
                subject = subject.Substring(0, idx);
            }

            //  Cut subject to specified length
            if (!string.IsNullOrEmpty(SubjectMaxLength))
            {
                int maxLength;
                if (int.TryParse(SubjectMaxLength, out maxLength))
                {
                    if (maxLength > 0 && subject.Length > maxLength)
                    {
                        subject = subject.Substring(0, maxLength);
                    }
                }
            }

            Subject = subject;
        }
开发者ID:anjlab,项目名称:fx,代码行数:63,代码来源:SmtpAppender.cs

示例8: Append

 protected override void Append(LoggingEvent loggingEvent)
 {
     TraderHubUtil.BroadcastLogMessage(new LogMessage()
     {
         LoggerName = loggingEvent.LoggerName,
         TimeStamp = loggingEvent.TimeStamp,
         Level = loggingEvent.Level.ToString(),
         Message = loggingEvent.RenderedMessage,
         ExceptionString = loggingEvent.GetExceptionString()
     });
 }
开发者ID:torkelo,项目名称:ScratchPad,代码行数:11,代码来源:SendToBrowserAppender.cs

示例9: Log_exception_string_without_object

        public void Log_exception_string_without_object()
        {
            var eventData = new LoggingEventData()
            {
                LoggerName = "logger",
                Message = "the message",
                ExceptionString = "Exception string",
            };
            var loggingEvent = new LoggingEvent(eventData);

            var logEvent = _logEventFactory.CreateLogEvent(loggingEvent);
            Assert.AreEqual(loggingEvent.RenderedMessage, logEvent["Message"]);
            Assert.AreEqual(loggingEvent.GetExceptionString(), logEvent["Exception"]);
            Assert.IsFalse(logEvent.ContainsKey("ExceptionObject"));
        }
开发者ID:cdzhoubin,项目名称:log4stash,代码行数:15,代码来源:LogEventFactory.cs

示例10: Log_exception

        public void Log_exception()
        {
            var loggingEvent = new LoggingEvent(
                this.GetType(),
                null,
                "logger.name",
                Level.Info,
                "message",
                new Exception("Exception string"));

            var logEvent = _logEventFactory.CreateLogEvent(loggingEvent);
            Assert.AreEqual(loggingEvent.RenderedMessage, logEvent["Message"]);
            Assert.AreEqual(loggingEvent.GetExceptionString(), logEvent["Exception"]);
            Assert.AreEqual(loggingEvent.ExceptionObject.Message, ((JsonSerializableException)logEvent["ExceptionObject"]).Message);
        }
开发者ID:cdzhoubin,项目名称:log4stash,代码行数:15,代码来源:LogEventFactory.cs

示例11: AzureLayoutLoggingEventEntity

        public AzureLayoutLoggingEventEntity(LoggingEvent e, PartitionKeyTypeEnum partitionKeyType, ILayout layout)
        {
            Level = e.Level.ToString();
            Message = e.RenderedMessage + Environment.NewLine + e.GetExceptionString();
            ThreadName = e.ThreadName;
            EventTimeStamp = e.TimeStamp;
            using (var w = new StringWriter())
            {
                layout.Format(w, e);
                Message = w.ToString();
            }

            PartitionKey = e.MakePartitionKey(partitionKeyType);
            RowKey = e.MakeRowKey();
        }
开发者ID:Thumann,项目名称:log4net.Azure,代码行数:15,代码来源:AzureLayoutLoggingEventEntity.cs

示例12: PreParse

 private JObject PreParse(LoggingEvent loggingEvent)
 {
     var exceptionString = loggingEvent.GetExceptionString();
      if (string.IsNullOrWhiteSpace(exceptionString))
      {
     exceptionString = null; //ensure empty strings aren't included in the json output.
      }
      var jobject = new JObject();
      jobject.Add("level", loggingEvent.Level.DisplayName);
      jobject.Add("time", loggingEvent.TimeStamp.ToString("yyyyMMdd HHmmss.fff zzz"));
      jobject.Add("machine", Environment.MachineName);
      jobject.Add("process", _currentProcess.ProcessName);
      jobject.Add("thread", loggingEvent.ThreadName);
       jobject.Add("message", JObject.FromObject(loggingEvent.MessageObject));
      jobject.Add("ex", exceptionString);
      return jobject;
 }
开发者ID:heneryville,项目名称:log4net-loggly,代码行数:17,代码来源:LogglyFormatter.cs

示例13: PreParse

 private object PreParse(LoggingEvent loggingEvent)
 {
     var exceptionString = loggingEvent.GetExceptionString();
     if (string.IsNullOrWhiteSpace(exceptionString))
     {
         exceptionString = null; //ensure empty strings aren't included in the json output.
     }
     return new
            	{
            		level = loggingEvent.Level.DisplayName,
            		time = loggingEvent.TimeStamp.ToString("yyyyMMdd HHmmss.fff zzz"),
                 machine = Environment.MachineName,
                 process = _currentProcess.ProcessName,
                 thread = loggingEvent.ThreadName,
                 message = loggingEvent.MessageObject,
                 ex = exceptionString,
            	};
 }
开发者ID:adamhathcock,项目名称:log4net-loggly,代码行数:18,代码来源:LogglyFormatter.cs

示例14: Append

 protected override void Append(LoggingEvent loggingEvent)
 {
     try
     {
         QueueLog(new LogMessage()
         {
             Exception = loggingEvent.GetExceptionString(),
             Level = loggingEvent.Level.Name,
             Message = loggingEvent.RenderedMessage,
             Thread = loggingEvent.ThreadName,
             Timestamp = loggingEvent.TimeStamp.ToString()
         });
     }
     catch (Exception ex)
     {
         //hide any exceptions to prevent logging exceptions/bottlenecks
     }
 }
开发者ID:chdev77,项目名称:Rest4Log4Net,代码行数:18,代码来源:Appender.cs

示例15: PreParse

        private object PreParse(LoggingEvent loggingEvent)
        {
            var exceptionString = loggingEvent.GetExceptionString();
            var message = loggingEvent.RenderedMessage;

            //ensure empty strings aren't included in the json output. Pass null instead.
            return new
                   	{
                   		level = loggingEvent.Level.DisplayName,
                   		time = loggingEvent.TimeStamp.ToString("yyyyMMdd HHmmss.fff zzz"),
                        machine = Environment.MachineName,
                        logger = loggingEvent.LoggerName,
                        process = loggingEvent.Domain,
                        thread = loggingEvent.ThreadName,
                        message = string.IsNullOrWhiteSpace(message) ? null : message,
                        ex = string.IsNullOrWhiteSpace(exceptionString) ? null : exceptionString,
                   	};
        }
开发者ID:mstueck,项目名称:log4net-loggly,代码行数:18,代码来源:LogglyFormatter.cs


注:本文中的log4net.Core.LoggingEvent.GetExceptionString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。