log4net.config file loading when using asp.net development server
So, I have log4net configuration in log4net.config file and I don't want to include it in the web.config. I initialize configuration in Application_Start like this
log4net.Util.LogLog.InternalDebugging = true;
log4net.Config.XmlConfigurator.Configure(new File开发者_JAVA技巧Info("log4net.config"));
But looking at the output window I see this
'WebDev.WebServer.exe' (Managed): Loaded 'Builders023dc0f3207c463dbe9f49f346e5a7ca.dll'
log4net: XmlConfigurator: configuring repository [log4net-default-repository] using file [log4net.config]
log4net: XmlConfigurator: config file [C:\Program Files\Common Files\Microsoft Shared\DevServer\9.0\log4net.config] not found. Configuration unchanged.
I cannot figure out how to provide a path to the config file so that it is not hardcoded and is relative. I tried ("../log4net.config"), ("~/log4net.config") etc. Is Server.MapPath only option?
Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, configFileName);
精彩评论