开发者

Trace log Example does not work in Sharepoint 2010

The Sharepoint Trace Log Sample given at http://开发者_JAVA百科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)


From How to write to ULS Log in SharePoint 2010 from a .NET app?

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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜