Skip to content

Commit

Permalink
SelfLog full exception info
Browse files Browse the repository at this point in the history
In some places only the exception message was written to SelfLog which is not sufficient. Use Exception.ToString() for all exceptions which this sink logs to Serilog SelfLog. ToString() adds exception type, message, call stack, inner exceptsions, etc.

Fixes issue #432.
  • Loading branch information
ckadluba committed Dec 30, 2022
1 parent 5a30ddc commit dc53566
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public async Task WriteBatch(IEnumerable<LogEvent> events, DataTable dataTable)
}
catch (Exception ex)
{
SelfLog.WriteLine("Unable to write {0} log events to the database due to following error: {1}", events.Count(), ex.Message);
SelfLog.WriteLine("Unable to write batch of {0} log events to the database due to following error: {1}",
events.Count(), ex);
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void WriteEvent(LogEvent logEvent)
}
catch (Exception ex)
{
SelfLog.WriteLine("Unable to write log event to the database due to following error: {0}", ex.Message);
SelfLog.WriteLine("Unable to write log event to the database due to following error: {0}", ex);
throw;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void CreateTable(DataTable dataTable)
}
catch (Exception ex)
{
SelfLog.WriteLine("Exception creating table {0}:\n{1}", _tableName, ex.ToString());
SelfLog.WriteLine("Unable to create database table {0} due to following error: {1}", _tableName, ex);
}
}
}
Expand Down

0 comments on commit dc53566

Please sign in to comment.