27 lines
915 B
C#
27 lines
915 B
C#
using Serilog;
|
|
|
|
namespace OF_DL.Helpers;
|
|
|
|
internal static class ExceptionLoggerHelper
|
|
{
|
|
/// <summary>
|
|
/// Logs an exception to the console and Serilog with inner exception details.
|
|
/// </summary>
|
|
/// <param name="ex">The exception to log.</param>
|
|
public static void LogException(Exception ex)
|
|
{
|
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.Message, ex.StackTrace);
|
|
Log.Error("Exception caught: {0}\n\nStackTrace: {1}", ex.Message, ex.StackTrace);
|
|
if (ex.InnerException == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Console.WriteLine("\nInner Exception:");
|
|
Console.WriteLine("Exception caught: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
|
ex.InnerException.StackTrace);
|
|
Log.Error("Inner Exception: {0}\n\nStackTrace: {1}", ex.InnerException.Message,
|
|
ex.InnerException.StackTrace);
|
|
}
|
|
}
|