Generate secret if not supplied and update logging