logging to file

I am trying to figure a way to have a log file and still keep the output in the terminal in a script.
The example below logs to a file nicely but i still want the output in the terminal as well

#!/bin/bash
#Create a log

exec >> /path/to/my/logfile

echo "hello world"

Any help would be much appreciated, ive played with tee am im sure thats the way, but just cant figure it out.

echo "This go to log (create it) and screen" | tee logfile.log

echo "This go to log (update it) and screen" | tee -a logfile.log

Hi,
I think tee is the way to go. The "-a" option is the key. Here's an example,

tail /var/log/messages | tee -a messy.log

this will give You stdout to console as well as written to a file.

/Lakris

Perhaps try the script utility program?