CONTRIB-5032: fixing logging detection in earlier versions and tidying code