File tree Expand file tree Collapse file tree 3 files changed +25
-8
lines changed
src/Serilog.Sinks.SqlServer Expand file tree Collapse file tree 3 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,7 @@ The `SqlServerSinkOptions` class inherits from `BatchingOptions` and provides th
220220| ` TableName ` | ` "LogEvent" ` | Name of the table to write logs to |
221221| ` TableSchema ` | ` "dbo" ` | Schema of the table |
222222| ` MinimumLevel ` | ` LevelAlias.Minimum ` | Minimum log event level |
223+ | ` LevelSwitch ` | ` null ` | Dynamic level switch for runtime level adjustments |
223224| ` BulkCopyOptions ` | ` SqlBulkCopyOptions.Default ` | SqlBulkCopy options for bulk insert operations |
224225| ` Mappings ` | ` MappingDefaults.StandardMappings ` | Column mappings for log event properties |
225226| ` BatchSizeLimit ` | ` 1000 ` | Number of log events to batch before writing (inherited) |
@@ -340,9 +341,9 @@ Log.Logger = new LoggerConfiguration()
340341 config .TableName = " LogExtended" ;
341342
342343 // Add custom property mappings
343- config .AddPropertyMapping (" ApplicationName" );
344- config .AddPropertyMapping (" ApplicationVersion" );
345- config .AddPropertyMapping (" EnvironmentName" );
344+ config .AddPropertyMapping (" ApplicationName" , size : 500 );
345+ config .AddPropertyMapping (" ApplicationVersion" , size : 500 );
346+ config .AddPropertyMapping (" EnvironmentName" , size : 500 );
346347 })
347348 .CreateLogger ();
348349```
Original file line number Diff line number Diff line change @@ -62,15 +62,13 @@ public static LoggerConfiguration SqlServer(
6262 string tableSchema = MappingDefaults . TableSchema ,
6363 LogEventLevel minimumLevel = LevelAlias . Minimum ,
6464 SqlBulkCopyOptions bulkCopyOptions = SqlBulkCopyOptions . Default ,
65- LoggingLevelSwitch ? levelSwitch = null
66- )
65+ LoggingLevelSwitch ? levelSwitch = null )
6766 {
6867 if ( loggerConfiguration is null )
6968 throw new ArgumentNullException ( nameof ( loggerConfiguration ) ) ;
7069
7170 if ( string . IsNullOrEmpty ( connectionString ) )
72- throw new ArgumentException ( $ "'{ nameof ( connectionString ) } ' cannot be null or empty.",
73- nameof ( connectionString ) ) ;
71+ throw new ArgumentException ( $ "'{ nameof ( connectionString ) } ' cannot be null or empty.", nameof ( connectionString ) ) ;
7472
7573 return SqlServer ( loggerConfiguration , sinkOptions =>
7674 {
Original file line number Diff line number Diff line change @@ -36,6 +36,11 @@ public static class MappingDefaults
3636 /// </summary>
3737 public const string MessageName = "Message" ;
3838
39+ /// <summary>
40+ /// The default column name for the log event message template.
41+ /// </summary>
42+ public const string TemplateName = "Template" ;
43+
3944 /// <summary>
4045 /// The default column name for the distributed tracing trace ID.
4146 /// </summary>
@@ -100,6 +105,19 @@ public static class MappingDefaults
100105 GetValue : static logEvent => logEvent . RenderMessage ( )
101106 ) ;
102107
108+ /// <summary>
109+ /// Gets the default column mapping for the log event message template.
110+ /// </summary>
111+ /// <remarks>
112+ /// Maps to a nullable string column containing the message template.
113+ /// </remarks>
114+ public static readonly ColumnMapping < LogEvent > TemplateMapping = new (
115+ ColumnName : TemplateName ,
116+ ColumnType : typeof ( string ) ,
117+ GetValue : static logEvent => logEvent . MessageTemplate ? . Text ,
118+ Nullable : true
119+ ) ;
120+
103121 /// <summary>
104122 /// Gets the default column mapping for the distributed tracing trace ID.
105123 /// </summary>
@@ -154,7 +172,7 @@ public static class MappingDefaults
154172 /// Gets the default column mapping for the source context property.
155173 /// </summary>
156174 /// <remarks>
157- /// Maps to a nullable string column with a maximum size of 1000 characters.
175+ /// Maps to a nullable string column with a maximum size of 1000 characters.
158176 /// Contains the source context (typically the full type name of the class creating the log event).
159177 /// </remarks>
160178 public static readonly ColumnMapping < LogEvent > SourceContextMapping = new (
You can’t perform that action at this time.
0 commit comments