There are occasions where you would like to have a log file include a timestamp for each line. The following script will allow you to do just that.
#!/bin/bash
while read x; do
echo -n `date +\[%Y-%m-%d\ %H:%M:%S.%3N]`;
echo -n " ";
echo $x;
done
... /path/to/command 2>&1 | /path/to/timestamp.sh >> /var/log/command.log