Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Use names in EventIds for logging #6818

Closed
analogrelay opened this issue Sep 14, 2017 · 6 comments
Closed

Use names in EventIds for logging #6818

analogrelay opened this issue Sep 14, 2017 · 6 comments
Labels
3 - Done cost: S Will take up to 2 days to complete enhancement PRI: 3 - Optional Represents a low-priority issue. Handle if time allows. up-for-grabs Members of our awesome commnity can handle this issue

Comments

@analogrelay
Copy link
Contributor

analogrelay commented Sep 14, 2017

When logging, we use ints for the eventId parameter, but the EventId type that is used can actually also support holding a name. Names are easier to query and inspect in structure log storage. So, as an example, a LoggerMessage.Define should change to something like this:

LoggerMessage.Define<...>(LogLevel.Trace, new EventId(1, "[Event Name]"), "... message ...");

(Event ID names don't need a prefix because EventId is only unique within a Logger, so there's no need to prefix it).

@josephearl
Copy link

Numeric event IDs are somewhat meaningless when looking through logs, this would be a great improvement.

@mkArtakMSFT mkArtakMSFT added this to the 2.2.0 milestone Jan 22, 2018
@mkArtakMSFT mkArtakMSFT added the PRI: 3 - Optional Represents a low-priority issue. Handle if time allows. label May 16, 2018
@mkArtakMSFT mkArtakMSFT modified the milestones: 2.2.0, 2.2.0-preview1 May 16, 2018
@mkArtakMSFT mkArtakMSFT added the cost: S Will take up to 2 days to complete label May 16, 2018
@mkArtakMSFT
Copy link
Member

@glennc, is this something we should prioritize for 2.2 milestone?

@glennc
Copy link
Member

glennc commented Aug 2, 2018

Changing existing eventIds would be a breaking change for customers, suddenly things parsing logs looking for numbers would need to change. Right?

Given that I don't think we could do something meaningful here in 2.2 at all, and I don't know if the improvement would ever be worth the potential pain. But we could have the discussion for new things we log, if we do that it should be all-or-nothing in that all components get strings instead of ints as we go forward.

@analogrelay
Copy link
Contributor Author

analogrelay commented Aug 2, 2018

suddenly things parsing logs looking for numbers would need to change. Right?

No, my understanding is that it is not breaking. It somewhat depends on the logging provider but Serilog, for example, tracks the Event ID and Event Name as separate data fields. So as long as we don't change the numbers, any queries that were based on "EventID = 123" should continue to work, we would just be additionally enabling queries based on "EventName = zoinks"

@mkArtakMSFT
Copy link
Member

/cc @glennc

@mkArtakMSFT
Copy link
Member

This is understood now. It's about logging additional data (the event name). Punting to a future release as we won't have time to handle this now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3 - Done cost: S Will take up to 2 days to complete enhancement PRI: 3 - Optional Represents a low-priority issue. Handle if time allows. up-for-grabs Members of our awesome commnity can handle this issue
Projects
None yet
Development

No branches or pull requests

6 participants