If you want your log file to be located in a specific place that will be determined at runtime, maybe your project output directory, then you can configure your entry in the .config file this way
file type="log4net.Util.PatternString" value="%property{LogFileName}.txt"
and then in the code, before calling log4net configure, set a new path as shown below
log4net.GlobalContext.Properties["LogFileName"] = @"E:\file1"; //log file path log4net.Config.XmlConfigurator.Configure();
So, if your requirement changes the log directory so often, then update the property value each time followed by .Configure() .
source share