in reply to Append the timestamp before and after the data in the logfile

On unix you can use this piece of code to add a timestamp to every line written to the log file:
select STDOUT; $| = 1; unless (open STDOUT, "|-") { eval { while(<>) { my $now = DateTime->now; print "$now: $_"; } }; exit(0); }
It uses DateTime to generate the timestamp but changing it to use localtime should be pretty simple.