2009-11-25 66 views
0

因此,我在log4net.config文件中配置了log4net,我不想將其包含在web.config中。我的Application_Start初始化配置這樣使用asp.net開發服務器時加載log4net.config文件

log4net.Util.LogLog.InternalDebugging = true; 
    log4net.Config.XmlConfigurator.Configure(new FileInfo("log4net.config")); 

但看在輸出窗口,我看到這個

'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. 

我無法弄清楚如何提供到配置文件的路徑,以便它不硬編碼和是相對的。我試過(「../log4net.config」),(「〜/ log4net.config」)等等。是否只有Server.MapPath選項?

回答

2
Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, configFileName); 
+0

謝謝very much gracias danke hvala :) – epitka 2009-11-25 19:34:52

相關問題