However, this requires context in the constructor.
Providing the construction of application components depends on the runtime data - this is an anti-pattern, as described here . This article describes how to solve these problems in general.
In your case, this probably means that your component should depend on the ASP.NET Core IHttpContextAccessor abstraction, and this is the template described in the reference article.
Alternatively, as described in the article, you can pass the necessary runtime data to the log using the Log method.
source share