Move all logger initialization into function