Logging now handles directories and file creation.