diff --git a/src/common/ManagedCommon/Logger.cs b/src/common/ManagedCommon/Logger.cs index 416a7aa042..bbc2637fd9 100644 --- a/src/common/ManagedCommon/Logger.cs +++ b/src/common/ManagedCommon/Logger.cs @@ -60,14 +60,29 @@ namespace ManagedCommon public static void LogError(string message, Exception ex) { - Log( - message + Environment.NewLine + - ex?.Message + Environment.NewLine + - "Inner exception: " + Environment.NewLine + - ex?.InnerException?.Message + Environment.NewLine + - "Stack trace: " + Environment.NewLine + - ex?.StackTrace, - Error); + if (ex == null) + { + LogError(message); + } + else + { + var exMessage = + message + Environment.NewLine + + ex.GetType() + ": " + ex.Message + Environment.NewLine; + + if (ex.InnerException != null) + { + exMessage += + "Inner exception: " + Environment.NewLine + + ex.InnerException.GetType() + ": " + ex.InnerException.Message + Environment.NewLine; + } + + exMessage += + "Stack trace: " + Environment.NewLine + + ex.StackTrace; + + Log(exMessage, Error); + } } public static void LogWarning(string message)