Try to create directories before opening a log file.