-
Notifications
You must be signed in to change notification settings - Fork 165
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
aspnet-request vars are empty in ASPNET Core 3.1 API #584
Comments
When #540 is merged and released, then things will get easier. But while waiting for that, then I guess the following clumsy work-around can be used: /* Register NLog.Web Extensions */
var dummy = LogginConfiguration();
NLogBuilder.ConfigureNLog(dummy);
/* Setup the actual confg, now has access to NLog.Web Extensions */
_logger = NLogBuilder.ConfigureNLog(config).GetCurrentClassLogger(); |
@snakefoot This produced the same results. |
@jchapmantcg The
You can setup the service-locator using public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
})
.UseNLog(); // NLog: Setup NLog for Dependency injection (Make ${aspnet-Request} work) See also: https://github.com/NLog/NLog/wiki/Getting-started-with-ASP.NET-Core-3 |
This is what I was missing! Thanks @snakefoot |
Type: Question/Bug
NLog version: 4.7.2
NLog.Web.AspNetCore version: 4.9.2
NLog.Extensions.Logging version: N/A
Platform: .NET Core 3.1
Current NLog config (xml or C#, if relevant)
In case of a BUG:
What is the current result?
All ${aspnet-request-xxxx} vars are empty
What is the expected result?
Values to be valid
Did you checked the Internal log?
Yes. It did not show anything related.
Are there any workarounds? yes/no
Not that I'm aware of.
Is there a version in which it did work?
No.
Can you help us by writing an unit test?
Yes.
The text was updated successfully, but these errors were encountered: