-
Notifications
You must be signed in to change notification settings - Fork 87
Add event ids to all publication sites #105
Conversation
@@ -154,7 +154,7 @@ private BCryptAlgorithmHandle GetSymmetricBlockCipherAlgorithmHandle(ILogger log | |||
|
|||
if (logger.IsVerboseLevelEnabled()) | |||
{ | |||
logger.LogVerboseF($"Opening CNG algorithm '{EncryptionAlgorithm}' from provider '{EncryptionAlgorithmProvider}' with chaining mode CBC."); | |||
logger.LogVerbose(DataProtectionEventId.CngCbcAuthenticatedEncryptionOptions, $"Opening CNG algorithm '{EncryptionAlgorithm}' from provider '{EncryptionAlgorithmProvider}' with chaining mode CBC."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Event ids should typically be unique within a single logging "category". Suggest you create specific ids for Hmac and SymmetricBlockCipher code paths.
Per comment, ensure unique event ids per logger category. Also, consider taking ILogger<> as ctor dependency parameter, rather than passing logger instance to individual methods. |
Our team uses a different style for logging. Take a look at these previous PRs that add logging: |
{ | ||
public enum DataProtectionEventId | ||
{ | ||
KeyServices = 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the PRs that I mentioned for our logging style. It's more clear
In MVC we don't log eventids In StaticFiles we have LoggerExtensions class with logging messages set as delegate fields and eventId just hardcoded in them. In Hosting we have LoggerExtensions class with log call's and level check in method bodies and event ids in seperate LoggerEventIds class with const fields. And we don't log eventids in some places (https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNet.Server.Testing/Common/RetryHelper.cs) So, what is our style for logging? |
MVC has event ids: https://github.com/aspnet/Mvc/blob/da731fc641f56529328d3cb74d6092310a40627e/src/Microsoft.AspNet.Mvc.Core/Logging/HttpStatusCodeResultLoggerExtensions.cs#L17 Use the delegate version when you have arguments to pass. Use the other when you don't. See this bug: aspnet/Logging#272 The pattern is:
|
@victorhurdugaci at the same time https://github.com/aspnet/Mvc/blob/da731fc641f56529328d3cb74d6092310a40627e/src/Microsoft.AspNet.Mvc.Core/Controllers/FilterActionInvoker.cs#L300 how do we decide if message needs eventId? |
We changed them later, I see |
I don't think MVC did a pass through all their messages to add event ids. They should all have ids. Event ids should be ideally unique. That's why having them in one place makes things easy. Also, they shouldn't change once set, that's why an enum might not be ideal. |
Yeah the pattern seen in https://github.com/aspnet/Mvc/blob/da731fc641f56529328d3cb74d6092310a40627e/src/Microsoft.AspNet.Mvc.Core/Logging/HttpStatusCodeResultLoggerExtensions.cs is the correct pattern. We have plenty of work items logged for us to update places where we don't yet use that new pattern. The new pattern follows all the logging best practices, and is also highly performant. |
Issue: #94
I renamed logging extension methods to be more EF like.
@anpete @muratg @victorhurdugaci @moozzyk