Sharepoint 'Unknown Error' Solution

Sharepoint is very bad when it comes to showing useful error. Even the log files does not contain information that can be considered useful. This is a big problem specially when programming webpart and other extensions. To change this behavior and get sharepoint to display detailed message Modify your web.config to set the following:

<SafeMode ... CallStack="true" ...>

<customErrors mode="Off" />

<compilation batch="true" debug="true">

All three of the modifications are required for full debug output.