【问题标题】:Log4Net : Error creating the web proxy specified in the 'system.net/defaultproxy' configuration sectionLog4Net:创建“system.net/defaultproxy”配置部分中指定的 Web 代理时出错
【发布时间】:2013-09-04 16:45:56
【问题描述】:

我有一个非常奇怪的错误:

在我的网络配置中,我有:

<system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\tmp\log4net.txt" />
      </listeners>
    </trace>

所以当我尝试通过我的代码连接 www.google.com(例如)时。我有错误:

Error creating the web proxy specified in the 'system.net/defaultproxy' configuration section

如果我从路径中删除 tmp 以拥有:

<system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\log4net.txt" />
      </listeners>
    </trace>

一切正常。

是不是很奇怪?

有人有想法吗?

【问题讨论】:

  • 您是否验证过 tmp 文件夹存在且 Web 进程有权写入该文件夹?
  • 当然,事实上如果我只更改 C:\log4net2.txt 的名称,它就不再起作用了

标签: c# web-config log4net


【解决方案1】:

我找到了,

我认为这是 IIS 中的错误。

问题是我的网站托管在 IIS 上,在这个网站上,我有一个用于我的 WebServices 的应用程序。

我的网站和我的网络服务有自己的 web.config。

但监听器名称在 2 web.config 上是相同的,所以当值不同时,我遇到了上述问题。

为了解决这个问题,我更改了侦听器的名称:

<system.diagnostics>
    <trace autoflush="true">
      <listeners>
        <add name="textWriterTraceListener2" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\tmp\log4net.txt" />
      </listeners>
    </trace>

name="textWriterTraceListener2" 用于 Web 服务,name="textWriterTraceListener" 用于网站。

但更好的是在 IIS 上将它们分开(我稍后会这样做) 谢谢大家的帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-28
    • 1970-01-01
    • 2012-05-11
    • 2010-11-12
    • 2015-01-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多