Move logger outside forever-running loop