Merged logging flush/close changes from 3.2.