<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    探索與發現

    研究java技術

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      83 隨筆 :: 0 文章 :: 109 評論 :: 0 Trackbacks

    I had previously written about using lo4net from Sharepoint
    by including all the configuration settings in the code.

    This certainly works, and its very easy.

    It would be good to be able to use a standard log4net configuration
    file though. In fact that would be great.

    And you can.

    FileInfo configFile = new FileInfo(_LOG4NET_CONFIGURATIONFILE);
    XmlConfigurator.Configure(configFile);

    It is that simple.

    In the code above _LOG4NET_CONFIGURATIONFILE is a configuration setting I read from the Sharepoint configuration file, but you can hardcode it instead.           

    You have to make sure that you put the configuration file in a location that Sharepoint can read from .

    One such place is

    C:\Inetpub\wwwroot\wss\VirtualDirectories\80

    I find it tidy to keep the log4net file next to the web.config file as well.

    You can also read from the web.config file that Sharepoint uses with this code:

    Configuration config = null;
    config = WebConfigurationManager.OpenWebConfiguration("/", "Sharepoint - 80");

     

     

     

    Phil Haack explains configuring log4net in asp.net 2.0 application. We can keep the configuration in the web.config, and we need to tell the log4net, that where we kept the configuration in the Application_Start() event using XmlConfiguration.Configure() menthod. In asp.net we can add a Global.asax and keep this code in Global.asax.cs.

    But how can we do this in Sharepoint?

    Every site collection we create in sharepoint, creates a globals.asax file and keeps in the webapp root directory. The asax files contains the following code.

    <%@ Assembly Name="Microsoft.SharePoint"%>
    <%@ Application Language="C#" Inherits="Microsoft.SharePoint.ApplicationRuntime.SPHttpApplication" %>

    We can add a inline code in the global.asax file as follows,

    <%@ Assembly Name="Microsoft.SharePoint"%>
    <%@ Assembly Name="log4net, version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821" %>
    <%@ Application Language="C#" Inherits="Microsoft.SharePoint.ApplicationRuntime.SPHttpApplication" %>
    <%@ Import Namespace="log4net.Config" %>

    <script runat="server">
    void Application_Start(Object sender, EventArgs e)
    {

    // Configure log4Net, to take its configuration from the web.config file.
    XmlConfigurator.Configure();
    }
    </script>

    or we can derive a class from SPHttpApplication and add the Application_Start() method.

     

    posted on 2009-02-11 07:09 蜘蛛 閱讀(360) 評論(0)  編輯  收藏 所屬分類: 日常瑣事
    主站蜘蛛池模板: 全免费a级毛片免费**视频| 四虎免费影院ww4164h| 理论片在线观看免费| 深夜久久AAAAA级毛片免费看| 久久免费香蕉视频| 中国人xxxxx69免费视频| 日韩亚洲精品福利| 亚洲AV无码成人网站久久精品大| 亚洲欧洲高清有无| 一级毛片免费播放视频| 成人免费一级毛片在线播放视频 | 亚洲乱码在线视频| 免费精品久久久久久中文字幕| 暖暖日本免费中文字幕| 国产成人青青热久免费精品| 精品亚洲综合在线第一区| 亚洲第一街区偷拍街拍| 999久久久免费精品播放| 亚洲精品无码你懂的网站| 亚洲乱人伦精品图片| 麻豆国产人免费人成免费视频| 日韩色日韩视频亚洲网站| 在免费jizzjizz在线播 | 精品亚洲成A人无码成A在线观看| 成人网站免费大全日韩国产| 日本一道在线日本一道高清不卡免费| 亚洲特级aaaaaa毛片| 国产精品色午夜免费视频| 精品一区二区三区高清免费观看| 婷婷亚洲综合五月天小说| 中文字幕在线视频免费观看 | 国产成人精品亚洲日本在线| 久久国产乱子免费精品| 久久精品国产亚洲av麻豆蜜芽 | 亚洲最大福利视频| 亚洲综合激情另类专区| 羞羞视频免费观看| 亚洲人成电影福利在线播放| 久久免费国产精品一区二区| 亚洲日韩av无码| 国产一二三四区乱码免费|