If you want to log error in 15 hive Logs folder than you have to use Diagnostics.asmx web service.
You can find list of all web service library on this link :
SharePointDiagnostics web service is used to communicate with Microsoft SharePoint Foundation 2010 diagnostic services. Client applications can call this web service to report errors and other diagnostic data.
We will use SendClientScriptErrorReport method present inside SharePointDiagnostics class.
Now lets get started –
Step 1 – Include _vti_bin/Diagnostics.asmx web service in your project.
Step 2 – Now make an object of SharePointDiagnostics class present in the web service reference.
Step 3 – Pass Credentials to SharePointDiagnostics class object.
Step 4 – Call SendClientScriptErrorReport method in SharePointDiagnostics class and pass (string message, string file, int line, Client client, string stack, Team team, string originalFile as arguments)
For example –
/// <param name="message">A string containing Message to be logged.</param> /// <param name="file">A string containing the location of the file from which the error is being generated.</param> /// <param name="line">A string containing the line of code from which the error is being generated.</param> /// <param name="client">A string containing the client name that is experiencing the error.</param> /// <param name="stack">A string containing the call stack information from the generated error.</param> /// <param name="team">A string containing a team or product name.</param> /// <param name="originalFile">A string containing the original file name.</param> SharePointDiagnostics SharePointDiagnosticsObject = new SharePointDiagnostics(); SharePointDiagnosticsObject.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials; string Response = SharePointDiagnosticsObject.SendClientScriptErrorReport(message, file, line, client, stack, team, originalFile);