serilog-mssql / serilog-sinks-mssqlserver

A Serilog sink that writes events to Microsoft SQL Server and Azure SQL
Apache License 2.0
278 stars 148 forks source link

Schema changes on SQL Server Log table once it created #467

Closed Git12San closed 1 year ago

Git12San commented 1 year ago

I have created a Log table with a few custom columns using Sinks-MSSqlServer and reading configuration settings from appsettings.json file. Is there any property to use on JSON to apply any DDL changes to apply in future on that table.

Its working when I make those changes on MS SqlServer manually and apply the same on JSON.

ckadluba commented 1 year ago

Hi @GitHub4Vinay! The sink can only create the log table if it does not exist. I will not do any DDL operations on the table if it already exists.

It is also a feature that was added for convenience when doing small demo and sample apps. For production scenarios most users create the table beforehand and then give the logging process only write permission on that table (principle of least privileges).

We have no plan to create a feature in the sink to alter existing log tables. If you need to do that, alter it by other means (TSQL script in SSMS etc.) and then adapt the sinks config to reflect the new schema.