# The aaplication begins with: my $err_file = "error.log"; open(ERRLOG, "+>>logs/system/$err_file"); flock(ERRLOG,2); *STDERR = *ERRLOG; # and ends with: flock(ERRLOG,8); close(ERRLOG);