Skip to content

Commit 64ec915

Browse files
author
Colin Young
committed
Merge branch 'dev' into custom-column-names
2 parents 31ab786 + c6dbc1a commit 64ec915

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/ColumnOptions.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public class ColumnOptions
1717
/// </summary>
1818
public ColumnOptions()
1919
{
20+
Id = new IdColumnOptions();
21+
2022
Level = new LevelColumnOptions();
2123

2224
Properties = new PropertiesColumnOptions();
@@ -67,30 +69,35 @@ public ICollection<StandardColumn> Store
6769
public ICollection<DataColumn> AdditionalDataColumns { get; set; }
6870

6971
/// <summary>
70-
/// Options for the Exception column.
72+
/// Options for the Id column.
7173
/// </summary>
72-
public ExceptionColumnOptions Exception { get; set; }
74+
public IdColumnOptions Id { get; private set; }
7375

7476
/// <summary>
75-
/// Options for the MessageTemplate column.
77+
/// Options for the Level column.
7678
/// </summary>
77-
public MessageTemplateColumnOptions MessageTemplate { get; set; }
79+
public LevelColumnOptions Level { get; private set; }
7880

7981
/// <summary>
80-
/// Options for the Message column.
82+
/// Options for the Properties column.
8183
/// </summary>
82-
public MessageColumnOptions Message { get; set; }
84+
public PropertiesColumnOptions Properties { get; private set; }
8385

8486
/// <summary>
85-
/// Options for the Level column.
87+
/// Options for the Exception column.
8688
/// </summary>
87-
public LevelColumnOptions Level { get; private set; }
89+
public ExceptionColumnOptions Exception { get; set; }
8890

8991
/// <summary>
90-
/// Options for the Properties column.
92+
/// Options for the MessageTemplate column.
9193
/// </summary>
92-
public PropertiesColumnOptions Properties { get; private set; }
94+
public MessageTemplateColumnOptions MessageTemplate { get; set; }
9395

96+
/// <summary>
97+
/// Options for the Message column.
98+
/// </summary>
99+
public MessageColumnOptions Message { get; set; }
100+
94101
/// <summary>
95102
/// Options for the TimeStamp column.
96103
/// </summary>
@@ -101,6 +108,11 @@ public ICollection<StandardColumn> Store
101108
/// </summary>
102109
public LogEventColumnOptions LogEvent { get; private set; }
103110

111+
/// <summary>
112+
/// Options for the Id column.
113+
/// </summary>
114+
public class IdColumnOptions : CommonColumnOptions { }
115+
104116
/// <summary>
105117
/// Options for the Level column.
106118
/// </summary>

src/Serilog.Sinks.MSSqlServer/Sinks/MSSqlServer/MSSqlServerSink.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ DataTable CreateDataTable()
161161
var id = new DataColumn
162162
{
163163
DataType = Type.GetType("System.Int32"),
164-
ColumnName = "Id",
164+
ColumnName = !string.IsNullOrWhiteSpace(_columnOptions.Id.ColumnName) ? _columnOptions.Id.ColumnName : "Id",
165165
AutoIncrement = true
166166
};
167167
eventsTable.Columns.Add(id);

0 commit comments

Comments
 (0)