Log4net 停止使用自定义渲染器
我有许多自定义对象渲染器,以便我可以使日志语句尽可能保持干燥。当我第一次部署我的应用程序时,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" />
这些渲染器都位于与进行日志记录的主程序独立的程序集中。我错过了什么或者做错了什么吗?我不知道为什么它不能立即识别渲染器,然后又忘记它们。
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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了答案。我必须为渲染的类包含更多的程序集信息。
成为
I found the answer. I had to include more of the assembly information for the rendered class.
Became