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

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

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

    探索與發(fā)現(xiàn)

    研究java技術(shù)

      BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      83 隨筆 :: 0 文章 :: 109 評(píng)論 :: 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 蜘蛛 閱讀(359) 評(píng)論(0)  編輯  收藏 所屬分類: 日常瑣事
    主站蜘蛛池模板: 成年人免费的视频| 中文字幕亚洲一区二区三区| 激情婷婷成人亚洲综合| 亚洲午夜激情视频| 亚洲香蕉免费有线视频| 亚洲人成未满十八禁网站| 亚洲精品tv久久久久| 毛片免费全部播放无码| 香蕉视频在线观看免费| 亚洲AV乱码一区二区三区林ゆな| 免费看少妇作爱视频| 男人的天堂网免费网站| www亚洲精品久久久乳| 亚洲人成电影在在线观看网色| 在线免费观看污网站| 日韩精品免费视频| 日韩亚洲人成在线综合| 久久综合亚洲色一区二区三区| 国产成人无码区免费A∨视频网站 国产成人涩涩涩视频在线观看免费 | 永久在线免费观看| 人妻无码中文字幕免费视频蜜桃 | 亚洲偷自精品三十六区| 国产亚洲精久久久久久无码77777 国产亚洲精品成人AA片新蒲金 | 性xxxx视频免费播放直播| 精品国产亚洲AV麻豆| 亚洲乱码在线视频| 无码乱人伦一区二区亚洲一| 免费乱理伦在线播放| 国产va免费精品观看精品 | 性色av免费观看| 114级毛片免费观看| 美女被免费网站91色| 国产成人精品日本亚洲语音| 亚洲精品国产成人| 亚洲va久久久噜噜噜久久狠狠| 亚洲国产专区一区| 免费无码不卡视频在线观看| 91免费人成网站在线观看18| 毛片在线全部免费观看| 亚欧国产一级在线免费| 色妞www精品视频免费看|