datalust / seq-extensions-logging

Add centralized log collection to ASP.NET Core apps with one line of code.
https://datalust.co/seq
Apache License 2.0
84 stars 12 forks source link

Support string interpolation #34

Closed fagnercarvalho closed 4 years ago

fagnercarvalho commented 4 years ago

It would be nice to support string interpolation so instead of doing this:

logger.LogInformation("Test {Response}", response);

We could just do this:

logger.LogInformation($"Test {response}");

Just to clarify, both of these include the log but only the first one adds the response variable as a log property.

nblumhardt commented 4 years ago

Thanks for the suggestion! A bit has been written on this already; unfortunately the design of string interpolation in C# makes it hard to do this well. I think this article and the comments capture the main issues/thinking: https://nblumhardt.com/2015/01/c-6-string-interpolation-and-serilog/

fagnercarvalho commented 4 years ago

It seems like I'm late to the party.

I thought this "new" C# feature could be used in this context but you made some excellent points in your article.

I'm closing this issue.

Thank you for your fast response!