The other way of accomplishing this task in doing it in perl. You can include this at the beginning of your document:
open STDERR,'> logfile' or die "Can't write to logfile: $!\n";
Or for compile time errors as well:
BEGIN { open STDERR,'> logfile' or die "Can't write to logfile: $!\n"; }
These techniques also allow redirection of errors in situations where you can't use shell features, such as in CGI scripts.