This can be used to redirect all output from a shell into a file or another process without sending it to the current shell:
bash exec > logfile ls cat /etc/passwd exit
cat logfile