Skip to content

AddLogging Extension method not compatible #16

@Rokerekor

Description

@Rokerekor

public static IServiceCollection AddLogging(this IServiceCollection services, Action<ILoggingBuilder> configure);
in the Microsoft.Extensions.Logging assembly will not work as expected. The translator will detect multiple ILoggingProviders and throw an exception. If only one is provided, it will not be injected properly and [Inject] will provide a Logger implementation that appears to do nothing.

I got around this by manually doing what the extension method does,

ILoggerFactory loggerFactory = LoggerFactory.Create(b => ...);
services.AddSingleton(loggerFactory)
services.TryAdd(ServiceDescriptor.Singleton(typeof(ILogger<>), typeof(Logger<>)));

Sorry if this is a terribly uninformed post. It took me a while to get logging working and I'm hoping this will be useful information to someone at some point.

Thanks for making this Kurai.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions