Closed isaacrlevin closed 5 years ago
Hasn't Logging.EventLog always done this? I didn't think this was new with generic host or worker template.
Yeah, I get the same warning out of a 2.2 web app.
The description for Event ID 2 from source Application cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
If the event originated on another computer, the display information had to be saved with the event.
The following information was included with the event:
Microsoft.AspNetCore.Hosting.Internal.WebHost
Request finished in 2.1067ms 200
The message resource is present but the message was not found in the message table
@Tratcher I was under the impression this was fixed at some point. If it is expected behavior, we can close
Transferring to Extensions for area-logging
. It's not a hosting issue. It does look like we won't be able to do much about it though since it appears to be caused by the fact that we log the user-provided Event ID to the Event Log and there is no description registered with Windows.
AFAIK this is the way this has always worked. What we have done in preview4 of the worker is log to a named source if we can. Which means if you create an event log source with the same name as your app then you will get logs without the error. We also automatically add the eventlog logger so you don't need that part of the code. Because we use the application name if your service is running with enough privileges to create sources then it will do it automatically without you needing to do anything else.
I would note that the logs are actually working, you get the log messages, but the error is also there.
I would either close this or add a docs label and make sure we've documented the behavior of worker in how it adds the event log logger and how to create a source for it.
In addition, outside of what we've done for worker, if you configure the eventlog logger to use a specific source name and create that source you will also not get the error.
Since we want the user to interact with this setting does it make sense to put it in configuration or code in the template as a placeholder?
Originally story was:
Currently I think we have 1 and 2, but not 3, and are unlikely to get 3 in 3.0. People need to know how to install the worker as a Windows Service and I think we can make this easier by putting the command to create the log source next to the command that creates the service in all our guidance.
I don't want to put code in that logs to a source that will likely not exist and throw whenever someone tries to run it without the right permissions to create a source. In fact I assume most people want to run it without those privileges so guidance for install time when you have admin rights seems the best option.
Describe the bug
Creating a Worker Service that logs to EventLog generates the below error
To Reproduce
.NET Core SDK (reflecting any global.json): Version: 3.0.100-preview3-010431 Commit: d72abce213
Runtime Environment: OS Name: Windows OS Version: 10.0.17763 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\
Host (useful for support): Version: 3.0.0-preview3-27503-5 Commit: 3844df9537
.NET Core SDKs installed: 3.0.100-preview3-010431 [C:\Program Files\dotnet\sdk]
Code Sample
CSPROJ
Expected behavior
Worker logs to EventLog successfully
Experienced Behavior
Error gets logged to EventView