public static Microsoft.Extensions.Logging.ILogger CreateILoggerFromNLog(bool debug = false)
        {
            // NLog build Example for microsoft ILogger find on :
            // https://stackoverflow.com/questions/56534730/nlog-works-in-asp-net-core-app-but-not-in-net-core-xunit-test-project
            var configuration = new NLog.Config.LoggingConfiguration();

            configuration.AddRuleForAllLevels(new NLog.Targets.ConsoleTarget());
            NLog.Web.NLogBuilder.ConfigureNLog(configuration);

            // Create provider to bridge Microsoft.Extensions.Logging
            var provider = new NLog.Extensions.Logging.NLogLoggerProvider();

            // Create logger
            Microsoft.Extensions.Logging.ILogger logger = provider.CreateLogger(typeof(DnsSrvToolsIntergrationTest).FullName);

            if (debug)
            {
                logger.LogDebug("This is a test of the log system : LogDebug.");
                logger.LogTrace("This is a test of the log system : LogTrace.");
                logger.LogInformation("This is a test of the log system : LogInformation.");
                logger.LogWarning("This is a test of the log system : LogWarning.");
                logger.LogError("This is a test of the log system : LogError.");
                logger.LogCritical("This is a test of the log system : LogCritical.");
            }

            return(logger);
        }
        internal static OktaConnectionContext GetConnectionContext(KeyedCollection <string, ConfigParameter> configParameters)
        {
            ProxyConfiguration proxyConfig = null;

            if (!string.IsNullOrWhiteSpace(OktaMAConfigSection.Configuration.ProxyUrl))
            {
                proxyConfig = new ProxyConfiguration()
                {
                    Host = OktaMAConfigSection.Configuration.ProxyUrl
                };
                logger.Info($"Using proxy host {proxyConfig.Host}");
            }

            logger.Info($"Setting up connection to {configParameters[ConfigParameterNames.TenantUrl].Value}");

            System.Net.ServicePointManager.DefaultConnectionLimit = OktaMAConfigSection.Configuration.ConnectionLimit;
            GlobalSettings.ExportThreadCount = OktaMAConfigSection.Configuration.ExportThreads;

            NLog.Extensions.Logging.NLogLoggerProvider f = new NLog.Extensions.Logging.NLogLoggerProvider();
            ILogger nlogger = f.CreateLogger("ext-logger");

            OktaClientConfiguration oktaConfig = new OktaClientConfiguration
            {
                OktaDomain        = configParameters[ConfigParameterNames.TenantUrl].Value,
                Token             = configParameters[ConfigParameterNames.ApiKey].SecureValue.ConvertToUnsecureString(),
                Proxy             = proxyConfig,
                ConnectionTimeout = OktaMAConfigSection.Configuration.HttpClientTimeout,
                MaxRetries        = 8,
            };

            HttpClient httpClient;

            if (OktaMAConfigSection.Configuration.HttpDebugEnabled)
            {
                logger.Warn("WARNING: HTTPS Debugging enabled. Service certificate validation is disabled");

                httpClient = OktaConnectionContext.CreateDebugHttpClient(nlogger, oktaConfig);
            }
            else
            {
                httpClient = DefaultHttpClient.Create(oktaConfig.ConnectionTimeout, proxyConfig, nlogger);
            }

            return(new OktaConnectionContext()
            {
                Client = new OktaClient(oktaConfig, httpClient, nlogger, new DefaultRetryStrategy(oktaConfig.MaxRetries ?? 8, 0, 1))
            });
        }