Automatically flush logWriter