For TFS 2010 we used:
context.TrackBuildMessage(message, BuildMessageImportance.High);
context.TrackBuildWarning(message);
context.TrackBuildError(message);
context.TrackBuildWarning(message);
For TFS 2012 there appears to only be a Track method on context. However my attempts at testing and tracking an error do not work and show me nothing in the build log.
context.Track(new CustomTrackingRecord(message, System.Diagnostics.TraceLevel.Error));