This has really improved in SharePoint 2010. Now you can write to the ULS logs easily even with SharePoint Foundation. All you have to do is this:
SPDiagnosticsCategory diagCat = new SPDiagnosticsCategory( "My category", TraceSeverity.Monitorable, EventSeverity.Error); SPDiagnosticsService diagSvc = SPDiagnosticsService.Local;diagSvc.WriteTrace(
0, // custom trace id diagCat,
TraceSeverity.Monitorable, // logging level of this record "Writing to the ULS log: {0}", // custom message new object[] { "SharePoint rocks!" } // parameters );
This will result in a nice entry in the SharePoint log file:

Works great, but not available in sandboxed solutions...