Polish log replace logic.