Extract logging setup into a separate function

Change-Id: I9f1761a5332ad3c4a8f0b76c6f46fc687fd61aa5