Saving for myself:
To log all bash sessions for all users in Linux, put this at the end of /etc/bash.bashrc:
if [ ! -d "/some/log/path/$USER/" ]; then
mkdir -p /some/log/path/$USER/
fi
if [ -d "/some/log/path/$USER/" ]; then
[[ "$(ps -ocommand= -p $PPID | awk '{print $1}')" = 'script' ]] || { script -f /some/log/path/$USER/$(date +"%Y-%m-%d_%H-%M-%S.%3N")_shell.log && exit ;}
fi
Thanks to the following two posts for the details to get the behavior I wanted (that behavior being: to log the sessions, and then exit the parent shell that spawned the script command as expected when I exit the script command, instead of simply exiting the script command and leaving me in the original bash shell):