Fix: logger failed when stdout was closed.