Log4net停止使用自定义渲染器 [英] Log4net stops using custom renderers

查看:81
本文介绍了Log4net停止使用自定义渲染器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有许多自定义对象渲染器,因此我可以将日志语句保持为DRY尽可能.首次部署应用程序时,log4net无法识别自定义渲染器,但可以正确执行其他所有操作.如果我触摸配置文件(使其看上去已更改),则文件查看器将获取更改,渲染器将开始工作.但是过了一段时间,他们又停止工作了,我不得不再次触摸log4net配置文件.

I have a number of custom object renderers so that I can keep my log statements as DRY as possible. When I first deploy my app log4net doesn't recognize the custom renderers but it does do everything else correctly. If I touch the config file it (make it looked changed) the file watcher picks up the change and the renderers start working. However after a time they stop working again and I have to touch the log4net config file again.

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

The setup is a .Net 3.5 (sp1) wcf application. The problem occurs in both the vs 2008 development web server and on IIS 7 on win 2008. I have a config file called log4net.config and I'm using the AssemblyInfo method for point at it.

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

我访问记录器的方式是通过在类上使用静态成员.

The way I access a logger is through the use of static members on the class like so.

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

渲染器的配置与此类似.

The renderers are configured similar to this.

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

这些渲染器都与正在进行日志记录的主系统位于单独的组件中.我是否缺少某些东西或做错了什么?我不知道为什么它不能立即识别渲染器,然后在以后再次忘记它们.

These renderers are all in a separate assembly from the main where the logging is taking place. Am I missing something or doing something wrong? I don't know why it doesn't recognize the renderers right away and then forgets them again later.

推荐答案

我找到了答案.我必须为渲染的类包括更多的组装信息.

I found the answer. I had to include more of the assembly information for the rendered class.

<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" /> 

这篇关于Log4net停止使用自定义渲染器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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