added logging mechanism and log retention