# How do I log to the SharePoint ULS logs from a Silverlight web part?

I am developing a Silverlight application which is to be hosted on a sharepoint 2010 page using the out of the box Silverlight webpart control. I want to log any exceptions to the sharepoint ULS logs which arise from the silverlight webpart.

I tried using the SharePointDiagnostics.SendClientScriptErrorReport method. However, I am getting an error regarding client certificate.

What do I need to do to fix this?

-

You could use the Diagnostics service (http://YourSite/_vti_bin/Diagnostics.asmx) as explained here http://msdn.microsoft.com/en-us/library/websvcdiagnostics.sharepointdiagnostics.sendclientscripterrorreport.aspx from any Client technology (Silverlight or Javascript), but it seems you would need to add the clientaccesspolicy.xml to allow access to the web service as explained here (http://msdn.microsoft.com/en-us/library/cc197955(VS.95).aspx) containing

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
<cross-domain-access>
<policy>
<domain uri="*"/>
</allow-from>
<grant-to>
<resource path="/" include-subpaths="true"/>
</grant-to>
</policy>
</cross-domain-access>
</access-policy>


in your C:\inetpub\wwwroot\wss\VirtualDirectories\80 (assuming you run on port 80)

-
Initially had to Hard code the Credentials as it was giving me an 401 Unauthorized error . Later on it works fine and SendClientErrorReport method from the Diagnostic service seems to complete with no error but the error is not logged in the 14\Logs folder –  Manoj Jun 27 '12 at 6:07
have you tried sending logs via a Console - just to validate that indeed Logging is properly functioning. –  C. Marius - MVP Jun 27 '12 at 15:13