Skip to content

Commit dc53566

Browse files
committed
SelfLog full exception info
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.
1 parent 5a30ddc commit dc53566

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlBulkBatchWriter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ public async Task WriteBatch(IEnumerable<LogEvent> events, DataTable dataTable)
5656
}
5757
catch (Exception ex)
5858
{
59-
SelfLog.WriteLine("Unable to write {0} log events to the database due to following error: {1}", events.Count(), ex.Message);
59+
SelfLog.WriteLine("Unable to write batch of {0} log events to the database due to following error: {1}",
60+
events.Count(), ex);
6061
}
6162
finally
6263
{

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlLogEventWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void WriteEvent(LogEvent logEvent)
7070
}
7171
catch (Exception ex)
7272
{
73-
SelfLog.WriteLine("Unable to write log event to the database due to following error: {0}", ex.Message);
73+
SelfLog.WriteLine("Unable to write log event to the database due to following error: {0}", ex);
7474
throw;
7575
}
7676
}

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform/SqlTableCreator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void CreateTable(DataTable dataTable)
4242
}
4343
catch (Exception ex)
4444
{
45-
SelfLog.WriteLine("Exception creating table {0}:\n{1}", _tableName, ex.ToString());
45+
SelfLog.WriteLine("Unable to create database table {0} due to following error: {1}", _tableName, ex);
4646
}
4747
}
4848
}

0 commit comments

Comments
 (0)