Debugging and Logging In Sharepoint Feature Development

How to write custom logs into ULS logs – SharePoint Foundation 2010 ( WSS 4.0)
http://blogs.msdn.com/b/sowmyancs/archive/2010/04/17/how-to-write-custom-logs-into-uls-logs.aspx


try{

} catch (Exception ex)
{
SPDiagnosticsService.Local.WriteTrace(
0,
new SPDiagnosticsCategory(“MSDN”, TraceSeverity.Unexpected, EventSeverity.Error),
TraceSeverity.Unexpected,
ex.Message,
ex.StackTrace);
}

Debugging and Logging Capabilities in SharePoint 2010
http://msdn.microsoft.com/en-us/library/gg512103.aspx

Chapter 3: Monitoring SharePoint 2010
http://msdn.microsoft.com/en-us/library/gg193966.aspx