SharePoint和Log4Net [英] SharePoint and Log4Net

查看:78
本文介绍了SharePoint和Log4Net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找将log4net集成到SharePoint中以进行Web请求,功能激活和所有计时器的最佳实践.

I'm looking for best practices to integrate log4net to SharePoint for web request, feature activation and all timer stuff.

我的服务器场中有几个子项目,并且我只想拥有一个Log4Net.config文件.

I have several subprojects in my farm, and I would like to have only one Log4Net.config file.


我不仅需要为Web应用程序配置log4net(这很容易做到)(我使用global.asax和一个log4net.config文件,因此可以在不重新加载Webapp的情况下修改日志设置),而且还需要异步记录日志事件:


Not only I need to configure log4net for the web application, which is easy to do (I use global.asax, and a log4net.config file, so I can modify log settings withtout reloading the webapp), but I also need to log asynchronous events:

  • 事件处理程序(如ItemAdded)
  • 计时器作业
  • ...

推荐答案

我最近实现了这一点,并提出了一个对我有用的解决方案.

I implemented this recently and came up with a solution that worked for me.

使用全局范围内的解决方案将log4net配置文件部署到12个配置单元中,并将log4net dll部署到GAC中.然后,在您的应用程序代码中,从全局文件的位置显式初始化log4net.这使您可以记录功能接收器,计时器作业和Web应用程序代码.

Deploy your log4net config file to the 12 hive and the log4net dll into the GAC using a globally scoped solution. Then in your application code explicitly initialize log4net from the location of your global file. This allows you to log feature receiver, timer jobs and web application code.

[assembly: log4net.Config.XmlConfigurator(ConfigFile = 
    @"C:\Program Files\Common Files\Microsoft Shared\" + 
    @"Web Server Extensions\12\CONFIG\log4net.config", Watch = true)]

请参见 http://www.codeproject.com/KB/sharepoint/SharepointLog4Net. aspx

这篇关于SharePoint和Log4Net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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