I know this is an old post, but why not just do this?
echo "hi" >> log.txt #stdout -> log
echo "hi" | tee -a log.txt #stdout -> log & stdout
echo "hi" &>> log.txt #stdout & stderr -> log
echo "hi" |& tee -a log.txt #stdout & stderr -> log & stdout
And of course, if you want stdout you can just print regularly.
You can do this with any combination of streams you wish, just using those two basic commands.
I know I came here and did not get an easy to understand/implement answer, hopefully this will be help to someone else who is struggling.
By the way, for noobs out there like my previous self, all the
tee command does is output the stdin input to both stdout and the file(s) specified as subsequent arguments.
-a stands for append, so you don't overwrite the file with every use of the command. If you have further questions, I find this to be a very helpful resource for quickly learning bash.