123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #region Apache License
- #endregion
- using System.Diagnostics;
- using System.IO;
- using log4net.Core;
- namespace log4net.Layout.Pattern
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- internal sealed class ExceptionPatternConverter : PatternLayoutConverter
- {
-
-
-
- public ExceptionPatternConverter()
- {
-
- IgnoresException = false;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- override protected void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- if (loggingEvent.ExceptionObject != null && Option != null && Option.Length > 0)
- {
- switch (Option.ToLower())
- {
- case "message":
- WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.Message);
- break;
- #if !NETCF
- case "source":
- WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.Source);
- break;
- case "stacktrace":
- WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.StackTrace);
- break;
- #if !NETSTANDARD1_3
- case "targetsite":
- WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.TargetSite);
- break;
- #endif
- case "helplink":
- WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.HelpLink);
- break;
- #endif
- default:
-
- break;
- }
- }
- else
- {
- string exceptionString = loggingEvent.GetExceptionString();
- if (exceptionString != null && exceptionString.Length > 0)
- {
- writer.WriteLine(exceptionString);
- }
- else
- {
-
- }
- }
- }
- }
- }
|