I've left pieces of this here and here. But perhaps a little code would help. :)
Public Class MyWebPart
Inherits Microsoft.SharePoint.WebPartPages.WebPart
Private Const TRACE_CLASS_ID As String = "MyWebPart"
Protected Overrides Sub RenderWebPart(ByVal output as System.Web.UI.HtmlTextWriter)
Dim TRACE_CATEGORY As String = TRACE_CLASS_ID + "RenderWebPart"
Try
Context.Trace.Write(TRACE_CATEGORY, "Trying something")
' Do something here
' pretend there is a variable
Context.Trace.Write(TRACE_CATEGORY, "variable value: " + variable)
output.Write("you html code goes here")
Catch ex As Exception
Context.Trace.Warn(TRACE_CATEGORY, ex.ToString)
End Try
End Sub