I know you can set NLog's internal log file programmatically like this:
NLog.Common.InternalLogger.LogFile = @"C:\Logs\nlog.log";
The above trick does not work for the following scenario, where I need to be able to set internal log file that's used by injected NLog. The one that gets created inside ASP.NET Core WebApi, using the following
.ConfigureLogging(logging =>
{
logging.SetMinimumLevel(LogLevel.Trace);
})
.UseNLog();
Are there any workarounds for me to programmatically configure LogFile and LogLeve of the NLog object that gets dependency injected?
CodePudding user response:
Why not just remove internalLogFile="..."
from NLog.{ASP_NET_CORE_ENVIRONMENT}.config
?
Or just re-assign InternalLogger.LogFile
after having called LogManager.Setup().LoadConfigurationFromAppSettings()
?