File tree Expand file tree Collapse file tree 3 files changed +14
-29
lines changed
src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/Platform Expand file tree Collapse file tree 3 files changed +14
-29
lines changed Original file line number Diff line number Diff line change 1
1
# 8.1.0
2
2
* Implemented #542 : Column option ` ResolveHierarchicalPropertyName ` to force non-hierarchical handling
3
-
4
- # 8.0.1
3
+ * Removed unnecessary exception handlers and let Serilog Core do the SelfLog()
5
4
* Refactoring and performance optimizations in batched and audit sink
6
5
* Create perftest result on release
7
6
* Updated issue template
Original file line number Diff line number Diff line change @@ -60,12 +60,6 @@ public async Task WriteBatch(IEnumerable<LogEvent> events)
60
60
}
61
61
}
62
62
}
63
- catch ( Exception ex )
64
- {
65
- SelfLog . WriteLine ( "Unable to write batch of {0} log events to the database due to following error: {1}" ,
66
- events . Count ( ) , ex ) ;
67
- throw ;
68
- }
69
63
finally
70
64
{
71
65
_dataTable . Clear ( ) ;
Original file line number Diff line number Diff line change @@ -43,34 +43,26 @@ public SqlInsertStatementWriter(
43
43
44
44
public async Task WriteEvents ( IEnumerable < LogEvent > events )
45
45
{
46
- try
46
+ using ( var cn = _sqlConnectionFactory . Create ( ) )
47
47
{
48
- using ( var cn = _sqlConnectionFactory . Create ( ) )
48
+ await cn . OpenAsync ( ) . ConfigureAwait ( false ) ;
49
+
50
+ foreach ( var logEvent in events )
49
51
{
50
- await cn . OpenAsync ( ) . ConfigureAwait ( false ) ;
52
+ var fields = _logEventDataGenerator . GetColumnsAndValues ( logEvent ) . ToList ( ) ;
53
+ InitializeSqlCommand ( cn , fields ) ;
51
54
52
- foreach ( var logEvent in events )
55
+ var index = 0 ;
56
+ _sqlCommand . ClearParameters ( ) ;
57
+ foreach ( var field in fields )
53
58
{
54
- var fields = _logEventDataGenerator . GetColumnsAndValues ( logEvent ) . ToList ( ) ;
55
- InitializeSqlCommand ( cn , fields ) ;
56
-
57
- var index = 0 ;
58
- _sqlCommand . ClearParameters ( ) ;
59
- foreach ( var field in fields )
60
- {
61
- _sqlCommand . AddParameter ( Invariant ( $ "@P{ index } ") , field . Value ) ;
62
- index ++ ;
63
- }
64
-
65
- await _sqlCommand . ExecuteNonQueryAsync ( ) . ConfigureAwait ( false ) ;
59
+ _sqlCommand . AddParameter ( Invariant ( $ "@P{ index } ") , field . Value ) ;
60
+ index ++ ;
66
61
}
62
+
63
+ await _sqlCommand . ExecuteNonQueryAsync ( ) . ConfigureAwait ( false ) ;
67
64
}
68
65
}
69
- catch ( Exception ex )
70
- {
71
- SelfLog . WriteLine ( "Unable to write log event to the database due to following error: {0}" , ex ) ;
72
- throw ;
73
- }
74
66
}
75
67
76
68
/// <summary>
You can’t perform that action at this time.
0 commit comments