简体   繁体   中英

What does the [] mean in the Microsoft.AspNetCore.Hosting.Internal.WebHost[1] asp.net trace message and how to find the corresponding code location?

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]

Log event ID

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM