Answers for "how to use ilogger without dependency injection"

1

how to use ilogger without dependency injection

public static class MyLogger
    {
        public static ILoggerFactory MyLoggerFactory { get; }

        static MyLogger()
        {
            MyLoggerFactory = LoggerFactory.Create(builder =>
            {
                builder
                    .AddFilter("Microsoft", LogLevel.Warning)
                    .AddFilter("System", LogLevel.Warning)
                    .AddFilter("LoggingConsoleApp.Program", LogLevel.Debug)
                    .AddConsole()
                    .AddEventLog();
            });
        }
    }
    
    ..In Class...
	private readonly ILogger _logger = new Logger<claTwilio>(MyLogger.MyLoggerFactory);
Posted by: Guest on August-05-2021

Code answers related to "how to use ilogger without dependency injection"

Browse Popular Code Answers by Language