Eli Robillard has given a good blog entry introducing the WSS/MOSS ULS log which is important for sharepoint troubleshooting:

#SharePoint Trace Logs and the Unified Logging Service (ULS)
http://weblogs.asp.net/erobillard/archive/2008/07/31/sharepoint-trace-logs-and-the-unified-logging-service-uls.aspx

Also, there is code sample in MSDN about how to write custom provider that helps write custom messages into ULS log:

#Trace Log Example
http://msdn.microsoft.com/en-us/library/aa979522.aspx