Log4Net“找不到架构信息"消息 [英] Log4Net "Could not find schema information" messages

查看:32
本文介绍了Log4Net“找不到架构信息"消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我决定使用 log4net 作为新网络服务项目的记录器.一切正常,但是对于我在 web.config 中使用的每个 log4net 标签,我收到了很多类似下面的消息:

I decided to use log4net as a logger for a new webservice project. Everything is working fine, but I get a lot of messages like the one below, for every log4net tag I am using in my web.config:

无法找到架构信息元素'log4net'...

Could not find schema information for the element 'log4net'...

以下是我的web.config的相关部分:

Below are the relevant parts of my web.config:

  <configSections>
    <section name="log4net" 
        type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  <log4net>
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <file value="C:log.txt" />
      <appendToFile value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="100KB" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level: %message%newline" />
      </layout>
    </appender>
    <logger name="TIMServerLog">
      <level value="DEBUG" />
      <appender-ref ref="RollingFileAppender" />
    </logger>
  </log4net>

已解决:

  1. 将每个 log4net 特定标记复制到单独的 xml 文件.确保使用 .xml 作为文件扩展名.
  2. 将以下行添加到 AssemblyInfo.cs:
  1. Copy every log4net specific tag to a separate xml-file. Make sure to use .xml as file extension.
  2. Add the following line to AssemblyInfo.cs:

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "xmlFile.xml", Watch = true)]

nemo 添加:

只是对任何人的警告遵循答案中的建议这个线程.有一种可能拥有 log4net 的安全风险根目录外的 xml 中的配置网络服务,因为它将是默认情况下任何人都可以访问.只是如果您的配置被告知包含敏感数据,您可能需要把它放在别处.

Just a word of warning to anyone follow the advice of the answers in this thread. There is a possible security risk by having the log4net configuration in an xml off the root of the web service, as it will be accessible to anyone by default. Just be advised if your configuration contains sensitive data, you may want to put it else where.

<小时>

@wcm:我尝试使用单独的文件.我将以下行添加到 AssemblyInfo.cs

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]

并将处理 log4net 的所有内容都放在该文件中,但我仍然收到相同的消息.

and put everything dealing with log4net in that file, but I still get the same messages.

推荐答案

我有不同的看法,需要以下语法:

I had a different take, and needed the following syntax:

[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.xml", Watch = true)]

这与 xsl 的上一篇文章不同,但对我来说有所不同.看看这个 博文,它帮了我.

which differs from xsl's last post, but made a difference for me. Check out this blog post, it helped me out.

这篇关于Log4Net“找不到架构信息"消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆