Reputation: 11492
I am trying to troubleshoot ASP.NET Core v2.1 issue and seeing the following statement in the trace log where I suspect my issue is happening:
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
What does the []
mean in this context and how do I find the code location that corresponds the [1]
inside the WebHost.cs
?
There are many more of these kid of trace messages in the log like:
dbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[4]
dbug: Microsoft.AspNetCore.Routing.Tree.TreeRouter[1]
trce: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
trce: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
Upvotes: 1
Views: 273
Reputation: 39072
This is the Log Event ID, see documentation.
It is helpful to quickly identify related logs, especially when you are logging custom messages. It is just a simple integer so it is worth defining a static class
with a list of integer constants so that you can then reuse the same ID on multiple places.
Upvotes: 1
Reputation: 81483
An event ID associates a set of events. For example, all logs related to displaying a list of items on a page might be 1001.
The logging provider may store the event ID in an ID field, in the logging message, or not at all. The Debug provider doesn't show event IDs. The console provider shows event IDs in brackets after the category:
info: TodoApi.Controllers.TodoController[1002]
Getting item invalidid
warn: TodoApi.Controllers.TodoController[4000]
GetById(invalidid) NOT FOUND
I belive you can only get stack trace information with line number with exception, though i may be wrong
Upvotes: 1