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

Ability to map structure log object properties to SQL Column #435

Closed szakula-hinda closed 1 year ago

szakula-hinda commented 1 year ago

The modern best practice for logging is to use structured logging, however this library lacks the ability to work with structured logging and map a structured object property to a SQL column.

I have searched the project and found this has been requested many times:

The last one even included a PR that was rejected.

Considering structured logging is the recommended best practice, this missing feature makes the library virtually unusable for modern projects. This should be prioritized

ckadluba commented 1 year ago

Hi @szakula-hinda!

Since so many people requested this, we should consider adding this. I'll think about a design.

In the mean time we are always happy to review good PRs that fit in and improve the sink. The PR you mentioned seemed not to provide the functionality you need.

Best regards, Christian

ckadluba commented 1 year ago

Actually this is a duplicate of #207 and therefore I will close this issue. Still we will consider to add this feature.

ckadluba commented 1 year ago

@szakula-hinda one more thing came to my mind. Please take a look at Serilog.Expressions. According to documentation samples it can handle message templates and resolve child properties and even array indexes in the template holes.

Does this help with your requirements?

https://github.com/serilog/serilog-expressions

ckadluba commented 1 year ago

Dear coders! today we merged the feature you requested to the dev branch (see linked PR) and the prerelease version 6.1.0-dev-00033 of the sink was built was uploaded to nuget.org. We would highly appreciate if you could give it a try and let us know what you think about it.

Best regards, Christian ✌️