private static void ExtendedWithException(ILogger logger, LogLevel logLevel, string message, object logProperties, Exception ex, int exceptionIndex, int exceptionCount, string tag) { var log = new LogEventInfo(logLevel, logger.Name, message); TransferDataObjectToLogEventProperties(log, logProperties); TransferContextDataToLogEventProperties(log); TransferScopeDataToLogEventProperties(log); if (ex != null) { log.Exception = ex; log.Properties.Add("ExceptionIndex", exceptionIndex); log.Properties.Add("ExceptionCount", exceptionCount); if (!string.IsNullOrEmpty(tag)) { log.Properties.Add("ExceptionTag", tag); } } #if NET452 var stackTrace = new StackTrace(0); log.SetStackTrace(stackTrace, StackHelper.IndexOfFirstCallingMethod(stackTrace.GetFrames())); // todo: There is still no netCore subsitiute for this! #endif logger.Log(log); }
private static void ExtendedWithException(ILogger logger, LogLevel logLevel, string message, object logProperties, Exception ex, int exceptionIndex, int exceptionCount, string tag) { var log = new LogEventInfo(logLevel, logger.Name, message); TransferDataToLogEventProperties(log, logProperties); if (ex != null) { log.Exception = ex; log.Properties.Add("ExceptionIndex", exceptionIndex); log.Properties.Add("ExceptionCount", exceptionCount); if (!string.IsNullOrEmpty(tag)) { log.Properties.Add("ExceptionTag", tag); } } var stackTrace = new StackTrace(0); log.SetStackTrace(stackTrace, StackHelper.IndexOfFirstCallingMethod(stackTrace.GetFrames())); logger.Log(log); }