private void doPrintln(long timeMillis, int logLevel, String tag, String msg) {
        String lastFileName = writer.getLastFileName();
        if (lastFileName == null || fileNameGenerator.isFileNameChangeable()) {
            String newFileName = fileNameGenerator.generateFileName(logLevel, System.currentTimeMillis());
            if (newFileName == null || newFileName.trim().length() == 0) {
                throw new IllegalArgumentException("File name should not be empty.");
            }
            if (!newFileName.equals(lastFileName)) {
                if (writer.isOpened()) {
                    writer.close();
                }
                cleanLogFilesIfNecessary();
                if (!writer.open(newFileName)) {
                    return;
                }
                lastFileName = newFileName;
            }
        }

        File lastFile = writer.getFile();
        if (backupStrategy.shouldBackup(lastFile)) {
            // Backup the log file, and create a new log file.
            writer.close();
            File backupFile = new File(folderPath, lastFileName + ".bak");
            if (backupFile.exists()) {
                backupFile.delete();
            }
            lastFile.renameTo(backupFile);
            if (!writer.open(lastFileName)) {
                return;
            }
        }
        String flattenedLog = flattener.flatten(timeMillis, logLevel, tag, msg).toString();
        writer.appendLog(flattenedLog);
    }
Do the real job of writing log to file.
android/android_framework/base/src/main/java/com/elvishew/xlog/printer/file/FilePrinter.java