Skip to content

Commit ab5e1fa

Browse files
rocknetcrockgmo
authored andcommitted
Update README
1 parent 6ea14d7 commit ab5e1fa

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ This is a `Collection<>` of `SqlColumn` objects that you create to define custom
320320
Each Standard Column in the `ColumnOptions.Store` list and any custom columns you add to the `AdditionalColumns` collection are `SqlColumn` objects with the following properties:
321321

322322
* `ColumnName`
323+
* `PropertyName`
323324
* `DataType`
324325
* `AllowNull`
325326
* `DataLength`
@@ -329,6 +330,10 @@ Each Standard Column in the `ColumnOptions.Store` list and any custom columns yo
329330

330331
Any valid SQL column name can be used. Standard Columns have default names assigned but these can be changed without affecting their special handling.
331332

333+
### PropertyName
334+
335+
The optional name of a Serilog property to use as the value for the SqlColumn. If not provided, the property used is the one that has the same name as the specified ColumnName.
336+
332337
### DataType
333338

334339
This property can be set to nearly any value in the `System.Data.SqlDbType` enumeration. Unlike previous versions of this sink, SQL column types are fully supported end-to-end, including auto-table-creation. Earlier limitations imposed by the use of the .NET `DataColumn` object no longer apply. Most of the Standard Columns only support a limited subset of the SQL column types (and often just one type). Some of the special-case SQL column types are excluded such as `timestamp` and `udt`, and deprecated types like `text` and `image` are excluded. These are the supported SQL column data types:
@@ -482,7 +487,7 @@ var columnOptions = new ColumnOptions
482487
AdditionalColumns = new Collection<SqlColumn>
483488
{
484489
new SqlColumn
485-
{ColumnName = "UserName", DataType = SqlDbType.NVarChar, DataLength = 64},
490+
{ColumnName = "EnvironmentUserName", PropertyName = "UserName", DataType = SqlDbType.NVarChar, DataLength = 64},
486491

487492
new SqlColumn
488493
{ColumnName = "UserId", DataType = SqlDbType.BigInt, NonClusteredIndex = true},
@@ -499,7 +504,7 @@ var log = new LoggerConfiguration()
499504
.CreateLogger();
500505
```
501506

502-
In this example, when a log event contains any of the properties `UserName`, `UserId`, and `RequestUri`, the property values would be written to the corresponding columns. The property names must match exactly (case-insensitive).
507+
In this example, when a log event contains any of the properties `UserName`, `UserId`, and `RequestUri`, the property values would be written to the corresponding columns. The property names must match exactly (case-insensitive). In the case of `UserName`, that value would be written to the column named `EnvironmentUserName`.
503508

504509
Unlike previous versions of the sink, Standard Column names are not reserved. If you remove the `Id` Standard Column from the `ColumnOptions.Store` list, you are free to create a new custom column called `Id` which the sink will treat like any other custom column fully under your control.
505510

@@ -568,6 +573,7 @@ As the name suggests, `columnOptionSection` is an entire configuration section i
568573
"additionalColumns": [
569574
{ "ColumnName": "EventType", "DataType": "int", "AllowNull": false },
570575
{ "ColumnName": "Release", "DataType": "varchar", "DataLength": 32 },
576+
{ "ColumnName": "EnvironmentUserName", "PropertyName": "UserName", "DataType": "varchar", "DataLength": 50 },
571577
{ "ColumnName": "All_SqlColumn_Defaults",
572578
"DataType": "varchar",
573579
"AllowNull": true,
@@ -632,6 +638,10 @@ Keys and values are case-sensitive. Case must match **_exactly_** as shown below
632638
</RemoveStandardColumns>
633639
<Columns>
634640
<add ColumnName="EventType" DataType="int"/>
641+
<add ColumnName="EnvironmentUserName"
642+
PropertyName="UserName"
643+
DataType="varchar"
644+
DataLength="50" />
635645
<add ColumnName="Release"
636646
DataType="varchar"
637647
DataLength="64"

0 commit comments

Comments
 (0)