AliBazzi / IdentityServer4.Contrib.RedisStore

A persistence layer using Redis DB for operational data and for caching capability for Identity Server 4
https://www.nuget.org/packages/IdentityServer4.Contrib.RedisStore
MIT License
137 stars 48 forks source link

Fix Logging #25

Closed hbiarge closed 4 years ago

hbiarge commented 4 years ago

Please, don´t use string interpolation when logging operations:

logger.LogDebug($"retrieved {typeof(T).FullName} with Key: {key} from Redis Cache successfully.");

Use always structured logging syntax to better performance and improve clarity with log stores that support structured logging. For example:

logger.LogDebug("retrieved {fullName} with Key: {key} from Redis Cache successfully.", typeof(T).FullName, key);
AliBazzi commented 4 years ago

Thanks for opening this, can I know why it's not recommended ?

hbiarge commented 4 years ago

The main reason is this (from the docs page https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-2.2#log-message-template)

"The logging framework works this way so that logging providers can implement semantic logging, also known as structured logging. The arguments themselves are passed to the logging system, not just the formatted message template. This information enables logging providers to store the parameter values as fields."

If you pass the formatted string, logger providers can´t identify those important values.

Hope this helps!

AliBazzi commented 4 years ago

Thanks for taking the time to PR this.