Skip to content

Added name for EventId in logs #11379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 4, 2019
Merged

Added name for EventId in logs #11379

merged 8 commits into from
Nov 4, 2019

Conversation

mikeo52
Copy link
Contributor

@mikeo52 mikeo52 commented Jun 19, 2019

Added name for EventId in Hosting, DataProtection, EntityFrameworkCore. #6381

@dnfclas
Copy link

dnfclas commented Jun 19, 2019

CLA assistant check
All CLA requirements met.

@Eilon Eilon added area-dataprotection Includes: DataProtection area-hosting labels Jun 19, 2019
Copy link
Contributor

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but we should remove the nameofs. Even though they reference LoggerEventIds, we still want to reduce the possibility of unintentionally changing these names without realizing.

@@ -172,7 +172,7 @@ private void LogRequestStarting(HttpContext httpContext)
// IsEnabled is checked in the caller, so if we are here just log
_logger.Log(
logLevel: LogLevel.Information,
eventId: LoggerEventIds.RequestStarting,
eventId: new EventId(LoggerEventIds.RequestStarting, nameof(LoggerEventIds.RequestStarting)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid nameof here. Even though we don't intent to change this, if we did ever change the name of the property it would break consumers. We started using nameof originally but decided it was better to just use string constants. The goal of nameof is to ensure that when you rename the target of the nameof expression, your reference is updated which is actually not what we want here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't thought about it that way at first, but I can see your point. This should be corrected in the latest commit.

Copy link
Contributor

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. It's unfortunate that some of these have 0 as the numeric event ID, but changing that is a breaking change and I don't think we want to do that.

@analogrelay
Copy link
Contributor

Build failures look unrelated. I'll restart.

@analogrelay
Copy link
Contributor

@Kahbazi
Copy link
Member

Kahbazi commented Aug 11, 2019

@anurse is there any chance that this could merge into asp.net core 3?

@Tratcher
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@Kahbazi
Copy link
Member

Kahbazi commented Aug 25, 2019

@mikeo52 Can you resolve the conflict?
I'm hoping this would reach the 3.0 version.

@Tratcher
Copy link
Member

FYI this is targeting the wrong branch for v3.x. It would need to be rebased and retargeted to release/3.0.

@Pilchie bar check for 3.x? Incremental diagnostic improvements.

@Pilchie
Copy link
Member

Pilchie commented Aug 26, 2019

It's very late for 3.0, but does fit into a diagnosability theme for 3.1.

@analogrelay
Copy link
Contributor

Oof, this got lost in some of the push to get 3.0 out the door. I'm going to respin the builds and see where we land. There is also a conflict to resolve.

@analogrelay
Copy link
Contributor

@mikeo52 are you up to try rebasing this on master and resolving the conflict so we can try to take this for 5.0 at least?

@mikeo52
Copy link
Contributor Author

mikeo52 commented Oct 21, 2019

@anurse yeah I updated it locally since there are just two spots where it's conflicting, but I'm having a lovely fun time merging because of the same error someone else reported below.

#15125

@mikeo52
Copy link
Contributor Author

mikeo52 commented Oct 21, 2019

Okay that makes absolutely no sense to me, but whatever. On this PR's merge conflicts screen I can edit the merge to my repo via the browser and resolve the conflicts, but if I use the git command line I constantly run into the other issue.

Copy link
Contributor

@analogrelay analogrelay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few small things. Looking good though. Thanks for resolving the conflict!

logLevel: LogLevel.Warning,
formatString: Resources.FileSystem_EphemeralKeysLocationInContainer);

_usingRegistryAsKeyRepositoryWithDPAPI = LoggerMessage.Define<string>(
eventId: 0,
eventId: new EventId(0, "UsingRegistryAsKeyRepositoryWithDPAPI"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is 5.0, I feel OK putting proper EventIds in place here.

For simplicity, I think it's OK to just use the same EventId sequence as the previous ones, even if these messages are used with different loggers. Thoughts @davidfowl ? It makes it easy to keep them consistent and EventIds are arbitrary anyway.

@mikeo52 can you continue the EventId number sequence with these last few events? (61, 62, 63...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anurse should be good to go with the latest commit.

@@ -175,7 +175,7 @@ private void LogRequestStarting(HostingApplication.Context context)

_logger.Log(
logLevel: LogLevel.Information,
eventId: LoggerEventIds.RequestStarting,
eventId: new EventId(LoggerEventIds.RequestStarting, "RequestStarting"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you could go to LoggerEventIds and change them from ints to EventId structs (you'd also have to change from const to static readonly fields but it's an internal type so I think that's OK. Could you give that a look @mikeo52 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@anurse I think I've got the change you were after made in this regard. Take a look and let me know. I'm having trouble building locally since my local setup's a little borked, so my apologies if the extra commits are making noise.

@@ -22,15 +22,15 @@ public static IDisposable RequestScope(this ILogger logger, HttpContext httpCont
public static void ApplicationError(this ILogger logger, Exception exception)
{
logger.ApplicationError(
eventId: LoggerEventIds.ApplicationStartupException,
eventId: new EventId(LoggerEventIds.ApplicationStartupException, "ApplicationStartupException"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we should try to just replace the LoggerEventIds constants themselves.

@Tratcher Tratcher merged commit 774f8db into dotnet:master Nov 4, 2019
@Tratcher
Copy link
Member

Tratcher commented Nov 4, 2019

Thanks

@Kahbazi
Copy link
Member

Kahbazi commented Nov 4, 2019

@Tratcher Is it possible to also merge this to 3.1?

@Tratcher
Copy link
Member

Tratcher commented Nov 4, 2019

No, 3.1 is only taking critical patches now.

@Kahbazi
Copy link
Member

Kahbazi commented Nov 4, 2019

I see, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dataprotection Includes: DataProtection area-hosting Includes Hosting
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants