add code to handle the situation of log directory does not exist