private void doPrintln(long timeMillis, int logLevel, String tag, String msg) {
    String lastFileName = writer.getOpenedFileName();
    boolean isWriterClosed = !writer.isOpened();
    if (lastFileName == null || isWriterClosed || fileNameGenerator.isFileNameChangeable()) {
      String newFileName = fileNameGenerator.generateFileName(logLevel, System.currentTimeMillis());
      if (newFileName == null || newFileName.trim().length() == 0) {
        Platform.get().error("File name should not be empty, ignore log: " + msg);
        return;
      }
      if (!newFileName.equals(lastFileName) || isWriterClosed) {
        writer.close();
        cleanLogFilesIfNecessary();
        if (!writer.open(new File(folderPath, newFileName))) {
          return;
        }
        lastFileName = newFileName;
      }
    }

    File lastFile = writer.getOpenedFile();
    if (backupStrategy.shouldBackup(lastFile)) {
      // Backup the log file, and create a new log file.
      writer.close();
      BackupUtil.backup(lastFile, backupStrategy);
      if (!writer.open(new File(folderPath, lastFileName))) {
        return;
      }
    }
    String flattenedLog = flattener.flatten(timeMillis, logLevel, tag, msg).toString();
    writer.appendLog(flattenedLog);
  }
Do the real job of writing log to file.
xlog/src/main/java/com/elvishew/xlog/printer/file/FilePrinter.java