fix potential memory leak for logger