Redirect stderr and log the return code