I keep meaning to post a link to Dan Sionov’s post on Logging scripts in Dynamics GP. Well now, I’ve remembered so here it is!
Logging Scripts in Dynamics GP
Archived post from 2009. Dynamics GP and the links it points to have changed since; check current documentation before relying on version-specific steps.