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"%>We can add a inline code in the global.asax file as follows,
<%@ Application Language="C#" Inherits="Microsoft.SharePoint.ApplicationRuntime.SPHttpApplication" %>
<%@ Assembly Name="Microsoft.SharePoint"%>or we can derive a class from SPHttpApplication and add the Application_Start() method.
<%@ 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>
Note, as i explained here you need to keep the log4net.dll in the _app_bin directory of your sharepoint webapplication.
Cheers,
Murugan G.