使用asp.net开发服务器时加载log4net.config文件
因此,我在 log4net.config 文件中有 log4net 配置,但我不想将其包含在 web.config 中。我像这样在 Application_Start 中初始化配置
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 是唯一的选项吗?
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 FileInfo("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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)