when a non-logged in user goes directly to the private forum
hey are redirected to a 404 page.
I’d like these users to be redirected to a log in page and then
redirected back to the private forum after having logged in.
this is nothing what the theme can provide to you. You would need to search for a plugin with such a function. Maybe something like https://de.wordpress.org/plugins/redirection/ is for you.