You can use Log4net to log your web services activities.
The implementation is the same of web application.
There are two ways to implement the initialization function in your web services.
The first solution is put your code into the Global.asax.
The second solution is put your code into the code behind file of Global.asax.
First of all add Global.asax file in your solution. Right click on the main project and select "Add New Item". In the new window, select "Global Application Class" and click Ok.
Open the Global.asax and put this code:
<%@ Application Language="C#" %>
<script runat="server">
private void Application_Start(Object sender, EventArgs e)
{
log4net.Config.DOMConfigurator.Configure();
}
</script>
If you want use the code behind file, open the Global.asax.cs file and put this code:
namespace MyWebServices
{
public class Global : System.Web.HttpApplication
{
protected void Application_Start(Object sender, EventArgs e)
{
log4net.Config.DOMConfigurator.Configure();
}
}
}
The Application_Start method is invoked when the Web Service is run for the first time (or reloaded).
If you want know to configure Log4net, see the relative posts on this site.