I've found this script (How to add timestamp to STDERR redirection) to redirect stdout/stderr of a script/program and add a time stamp:
#!/bin/bash
while read line ; do
echo "$(date): ${line}"
done
when using this script (predate.sh) like
./MyApp | predate.sh > out.log
it works great, but when MyApp crashes or gets killed, the predate.sh script continuously runs and does not terminate. Does anyone know how to solve that?