Skip to content

Log4ALA 2.2.1

Compare
Choose a tag to compare
@moberacker moberacker released this 03 Jul 07:57

Fix issue with ASP.Net Core 2.0 while using Microsoft.Extensions.Logging.Log4Net.AspNetCore which will ignore and fail loading the internalLog4net.config and therefore leads to stop logging internal error/info logfiles. The reason is that internalLog4net.config will be installed as project content file during the nuget package installation. To solve this problem we now include internalLog4net.config as EmbeddedResource as by dependent .NET Framework >= 4.5 installations. Now for .NET Standard 2.0 package installations it's also possible to override all Log4ALA configuration settings normally done in appsetings.json programmatically during runtime by setting the depending environment variable with dotnetcore appsettings notation e.g.:

// path = D:\home\LogFiles\Log4Net if your ASP.NET Core App will be deployid as Azure App Service
var path = Path.Combine(System.Environment.GetEnvironmentVariable("HOME"), "LogFiles", "Log4Net");
System.Environment.SetEnvironmentVariable("Log4ALAAppenderAll:errAppenderFile", Path.Combine(path, "log4ALA_error.log"));
System.Environment.SetEnvironmentVariable("Log4ALAAppenderAll:infoAppenderFile", Path.Combine(path, "log4ALA_info.log"));

or by using appsettings.{env.EnvironmentName}.json (env.EnvironmentName => ASPNETCORE_ENVIRONMENT environment variable) for ASP.NET Core Apps. The order how the settings will be overwritten or extended is:
appsettings.json => appsettings.{env.EnvironmentName}.json => System.Environment.SetEnvironmentVariable(...)