Use process substitution with & redirection and exec:
exec &> >(tee -a "$log_file")
echo This"This will be logged to the file and to the screenscreen"
$log_file will contain the output of the script and any subprocesses, and the output will also be printed to the screen.
>(...) starts the process ... and returns a file representing its standard input. exec &> ... redirects both standard output and standard error into ... for the remainder of the script (use just exec > ... for stdout only). tee -a appends its standard input to the file, and also prints it to the screen.
>(...)starts the process...and returns a file representing its standard input.exec &> ...redirects both standard output and standard error into...for the remainder of the script (use justexec > ...for stdout only).tee -aappends its standard input to the file, and also prints it to the screen.