Log4Slack
Log4Slack copied to clipboard
Inner exceptions
Thanks for a great little utility!
I'm missing the inner exceptions in the logging, sometimes they might say more about the error than the actual exception.
I've added this little code in a local copy - Is this something that you would like to see as PR? Maybe we could use a setting or something if we don't want to include it by default? "IncludeInnerException"
`if (exception!= null && exception.InnerException != null)
{
theAttachment.Fields.Insert(0, new Field("Inner Exception Type", Value: exception.InnerException.GetType().Name, Short: true));
if (AddExceptionTraceField && !string.IsNullOrWhiteSpace(exception.InnerException.StackTrace))
{
var parts = exception.InnerException.StackTrace.SplitOn(1990).ToArray(); // Split call stack into consecutive fields of ~2k characters
for (int idx = parts.Length - 1; idx >= 0; idx--)
{
var name = "Inner exception Trace" + (idx > 0 ? string.Format(" {0}", idx + 1) : null);
theAttachment.Fields.Insert(0, new Field(name, Value: "```" + parts[idx].Replace("```", "'''") + "```"));
}
}
theAttachment.Fields.Insert(0, new Field("Inner Exception Message", Value: exception.InnerException.Message));
}`
Let me know what you think.
@enkelmedia, thanks so much for this! Apologies for the long wait on a response. This would be great as a PR, and having a setting on whether or not to include the inner exception makes sense.