-
Notifications
You must be signed in to change notification settings - Fork 5k
No information about application is recorded when WindowsEventLog class failed to write event log #116178
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
Conversation
I think it would be more useful for troubleshooting if process name is included in the message as well. |
runtime/src/libraries/System.Diagnostics.EventLog/src/System/Diagnostics/EventLog.cs Lines 180 to 186 in 0f2bfae
The source name should be helping partially with that. Passing down the process name requires changing the public interfaces of the library so we can pass down the process id and lookup the process name. @tarekgh do you see another way to get the process name ? |
Yes, this will be challenging, especially since remote logging may not always include the process name. Additionally, Windows doesn’t provide this by default, and we should probably avoid implementing it ourselves to stay consistent with the platform's behavior. |
@pedrobsaila thanks for providing the change! Could you please add some test for this case in the file https://github.com/dotnet/runtime/blob/main/src/libraries/System.Diagnostics.EventLog/tests/EventLogTests/EventLogTests.cs Add the test case with the following condition: private bool static IsNetCoreAndNotElevatedAndSupportsEventLogs => PlatformDetection.IsNetCore && Helpers.NotElevatedAndSupportsEventLogs;
[ConditionalFact(nameof(IsNetCoreAndNotElevatedAndSupportsEventLogs))] Then you can do something like new EventLog("Application, ".", "EventSourceNameShouldnotExist").WriteEntry("Some Message"); And validate the thrown exception and the exception message. I didn't try it so please try to run the new test locally before submitting it. |
…ss failed to write event log
/ba-g the failures are not related, and it is infrastructure specific. |
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.
Thanks @pedrobsaila
Fixes #116022