Microsoft has a great piece of example code that you can copy and paste into your solution and start using on how to write to the SharePoint trace log. these are the log files that get created from setting up "Diagnostic Logging" under Central Administration -> Operations. I have used it in the past and it works pretty well.
http://msdn2.microsoft.com/en-us/library/aa979590.aspx