using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using NLog.Web; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace EVCB_OCPP.WSServer.Helper { public static class AddLogServcieExtention { public static IHostBuilder AddLogServcie(this IHostBuilder hostBuilder) { string loggerSelectString = ""; hostBuilder.ConfigureLogging((context, loggingBuilder) => { loggerSelectString = context.Configuration["LogProvider"]; loggingBuilder.ClearProviders(); if (loggerSelectString == "Azure") { loggingBuilder.AddAzureWebAppDiagnostics(); return; } if (loggerSelectString == "Console") { loggingBuilder.AddConsole(); return; } NLog.LogManager.Configuration = new NLogLoggingConfiguration(context.Configuration.GetSection("NLog")); }); if (loggerSelectString != "Azure") { hostBuilder.UseNLog(); } return hostBuilder; } } }