Skip to content

No way to use LogFactory with AspNet.Core #541

@ilya-spv

Description

@ilya-spv

Type (choose one):

  • Feature request

NLog version: 4.7

NLog.Web/NLog.Web.AspNetCore version: 4.9.1

NLog.Extensions.Logging version: 1.6.2

Platform: .NET Core 3

NLog 4.7 comes with new Setup methods combined in LogFactory to make things easier to configure if I understood it correctly. I have tried to use this feature with Asp.NetCore, but I did not figure out how and it seems impossible.

I have gone a bit though code and in registering a provider have found this:

private static NLogLoggerProvider CreateNLogLoggerProvider(
      IServiceProvider serviceProvider,
      IConfiguration configuration,
      NLogAspNetCoreOptions options)
    {
      return AspNetExtensions.CreateNLogLoggerProvider(serviceProvider, configuration, options, (LogFactory) null);
    }

It seems that though the option exists in code it is not exposed and hardcoded to null. It would be nice to have this possibility via AspNet.Core.

I have used: UseNLog() extension method.

It might it's already being implemented in this commit?

P.S. Not sure it's required anymore as it's possible to use Setup methods directly on LogManager.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions