The Sharepoint Trace Log Sample given at http://msdn.microsoft.com/en-us/library/aa979522.aspx & explained at /en-us/library/aa979595.aspx does not work in in Sharepoint 2010. Any ideas of how to Write to Trace Log from webpart( non-sandboxed)
A:
I am also using the sample given on MSDN, it is working fine with MOSS 2007 and not working with Sharepoint 2010. Any help on this is appreciated.
Lalitha
2010-03-09 05:08:04
+1
A:
This has really improved in SP2010. Now you can write to the ULS logs easily even with SharePoint Foundation. All you have to do is this:
SPDiagnosticsService diagSvc =
SPDiagnosticsService.Local;
diagSvc.WriteTrace( 0, // custom trace
id
new SPDiagnosticsCategory("My category",
TraceSeverity.Monitorable,
EventSeverity.Error), // create a category
TraceSeverity.Monitorable, // set the logging level of this record
"Writing to the ULS log: {0}", // custom message
new object[] { "SharePoint rocks!"} // parameters to message );
Works great, but not available in sandboxed solutions...
Hasan Khan
2010-03-26 08:01:55