Method WriteException
WriteException(ILogWriter, Exception)
Writes detailed information about the specified exception to the log, including its type, message, and stack trace.
public static ILogWriter WriteException(this ILogWriter writer, Exception ex)
Parameters
writerILogWriterThe log writer to which the exception details will be written. Cannot be null.
exExceptionThe exception whose details are to be logged. Cannot be null.
Returns
- ILogWriter
The same ILogWriter instance that was provided, to support method chaining.
Remarks
This method writes the exception details within a dedicated section in the log. If the exception's stack trace is null, an empty string is written in its place.
WriteException(ILogWriter, string, Exception)
Writes detailed information about an exception, including its type, message, and stack trace, to the log writer as a formatted section.
public static ILogWriter WriteException(this ILogWriter writer, string message, Exception ex)
Parameters
writerILogWriterThe log writer to which the exception details are written. Cannot be null.
messagestringA descriptive message providing context for the exception.
exExceptionThe exception to log. Cannot be null.
Returns
- ILogWriter
The same ILogWriter instance that was provided, to support method chaining.
Remarks
The exception details are written as a distinct section in the log output. This method is intended to standardize exception logging and improve log readability.