For this app (CMS) Log4net is configured in Config/log4net.config.
I need to set the path for where the log file should be placed dynamically at runtime.
I have tried adding the following code to global.asax (and OnApplicationStarting)
log4net.GlobalContext.Properties["path"] = "testlog";
log4net.Config.XmlConfigurator.Configure();
plus changed the configuration to
<file type="log4net.Util.PatternString" value="c:\Logs\%property{path}\AppLog.log" />
in log4net.config
It starts with creating a directory c:\Logs\(null)\AppLog.log - and begins logging - and after a short while it creates the wanted directory - c:\Logs\testlog\AppLog.log - and continues the logging in this directory.
I seem not to be able to hook in before the logging starts. Anybody having a solution or idea about how I should do it - so I do not get the (null) directory first?
Can i somehow access a value set in web.config and use this as the dynamic part in the folder name?