Fix a memory leak in logging