【问题标题】:Log4net stops using custom renderersLog4net 停止使用自定义渲染器
【发布时间】:2011-08-17 22:57:45
【问题描述】:

我有许多自定义对象渲染器,因此我可以使我的日志语句尽可能干燥。当我第一次部署我的应用程序时,log4net 无法识别自定义渲染器,但它确实可以正确执行其他所有操作。如果我触摸配置文件(使其看起来已更改),文件观察器将获取更改并且渲染器开始工作。但是过了一段时间他们又停止工作了,我不得不再次触摸 log4net 配置文件。

安装程序是一个 .Net 3.5 (sp1) wcf 应用程序。这个问题出现在 vs 2008 开发 web 服务器和 win 2008 上的 IIS 7 上。我有一个名为 log4net.config 的配置文件,我正在使用 AssemblyInfo 方法指向它。

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

我访问记录器的方式是通过使用类上的静态成员,就像这样。

private static readonly ILog log = LogManager.GetLogger(typeof(Service));

渲染器的配置与此类似。

<renderer renderingClass="MyCompany.Log4net.SearchRequestRenderer, MyCompany.Log4net" renderedClass="System.DirectoryServices.Protocols.SearchRequest" />

这些渲染器都在一个单独的程序集中,与发生日志记录的主程序不同。我错过了什么或做错了什么?我不知道为什么它不能立即识别渲染器,然后又忘记了它们。

【问题讨论】:

    标签: c# .net wcf log4net


    【解决方案1】:

    我找到了答案。我必须为渲染的类包含更多的程序集信息。

    <renderer renderingClass="MyCompany.Log4net.SearchRequestRenderer, MyCompany.Log4net" renderedClass="System.DirectoryServices.Protocols.SearchRequest" />
    

    成为

    <renderer renderingClass="MyCompany.Log4net.SearchRequestRenderer, MyCompany.Log4net" renderedClass="System.DirectoryServices.Protocols.SearchRequest, System.DirectoryServices.Protocols, Version=2.0.0.0 , Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> 
    

    【讨论】:

      猜你喜欢
      • 2018-06-17
      • 2017-06-09
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 2017-11-24
      • 2013-09-25
      • 2011-07-14
      • 1970-01-01
      相关资源
      最近更新 更多