I'd like to log stuff in my Sharepoint Web Parts, but I want it to go into the ULS. Most examples that I've found log into the Event Log or some other file, but I did not really find one yet for logging into the ULS.
Annoyingly, Microsoft.SharePoint.Diagnostics Classes are all marked Internal. I did find one example of how to use them anyway through reflection, but that looks really risky and unstable, because Microsoft may change that class with any hotfix they want.
The Sharepoint Documentation wasn't really helpful either – lots of Administrator info about what ULS is and how to configure it, but i have yet to find an example of supported code to actually log my own events.
Any hints or tips?
Edit: As you may see from the age of this question, this is for SharePoint 2007. In SharePoint 2010, you can use SPDiagnosticsService.Local and then WriteTrace. See the answer from Jürgen below.
Best Answer
Yes this is possible, see this MSDN article: http://msdn2.microsoft.com/hi-in/library/aa979595(en-us).aspx
And here is some sample code in C#:
}