Getting the w3wp.exe ProcessID for Attach to Process
Open command prompt and type iisapp.vbs
Attach a debugger to your code
Use Debug and Trace statements
System.Diagnostics.Debug and Trace statements are another great way of tracking down errors in your code. As Debug calls are removed from release builds, these can be used extensively to help track down errors in development. To view these you can use tools such as DebugView to view messages on local or remote machines
Use Try-Catch statements
As with standard ASP.NET applications, Try-Catch statements can help catch and log error messages that occur in your code. This can be combined with Debug and Trace statements to view or log errors, or display meaningful messages to the user. For example in a web control you might do the following:
protected override void Render(HtmlTextWriter writer)
{
try
{
// code that might cause an error
}
catch
{
Trace.Write(ex);
writer.Write(ex.Message);
}
}
View the SharePoint Logs
The raw SharePoint log files are extremely cluttered and hard to use but there is an alternative. The LogViewer feature on CodePlex lets you easily select a log file and view a filtered display of the items you are interested in.
You can also tweak the information that is written to the SharePoint logs via the Diagnostic Logging link under Logging and Reporting in the operations section of Central Administration.