How to log Properties data as JSON instead of XML in serilog SQL sink How to log Properties data as JSON instead of XML in serilog SQL sink json json

How to log Properties data as JSON instead of XML in serilog SQL sink


How you do it is super confusing and not inline with some of the other libraries.

First here is an Args property of a config for MSSQLServerSink

"Args": {    "tableName": "TestMvcClient",    "schemaName": "dbo",    "autoCreateSqlTable": true,    "columnOptionsSection": {        "addStandardColumns": [ "LogEvent" ], /* Use JSON Column LogEvent */        "removeStandardColumns": [ "Properties" ], /* Remove XML Column Properties */    }}

You can find it and 20+ other settings at the Serilog source.
https://github.com/serilog/serilog-sinks-mssqlserver#custom-property-columns


That's a limitation of SQL Server, itself, not Serilog. SQL Server doesn't support JSON, but it does have an XML column type, which is why that's used by Serilog there.