Is it possible to output LOGS to a SPIFFS file that's inside the ESP32?

This is the code:

#include <Arduino.h>
#include <WiFi.h>
#include <HTTPClient.h>
#include <ESPAsyncWebServer.h>
#include <stdarg.h>
#include <stdio.h>
#include <SPIFFS.h>

const char* ssid = "SSID";
const char* password =  "password";

AsyncWebServer server(80);

static char log_print_buffer[512];

int vprintf_into_spiffs(const char* szFormat, va_list args) {
	//write evaluated format string into buffer
	int ret = vsnprintf (log_print_buffer, sizeof(log_print_buffer), szFormat, args);

	//output is now in buffer. write to file.
	if(ret >= 0) {
    if(!SPIFFS.exists("/LOGS.txt")) {
      File writeLog = SPIFFS.open("/LOGS.txt", FILE_WRITE);
      if(!writeLog) Serial.println("Couldn't open spiffs_log.txt"); 
      delay(50);
      writeLog.close();
    }
    
		File spiffsLogFile = SPIFFS.open("/LOGS.txt", FILE_APPEND);
		//debug output
		//printf("[Writing to SPIFFS] %.*s", ret, log_print_buffer);
		spiffsLogFile.write((uint8_t*) log_print_buffer, (size_t) ret);
		//to be safe in case of crashes: flush the output
		spiffsLogFile.flush();
		spiffsLogFile.close();
	}
	return ret;
}

void setup() {
 
  Serial.begin(115200);
  delay(1000);
  if (!SPIFFS.begin(true)) {
    Serial.println("An Error has occurred while mounting SPIFFS");
    return;
  }
  esp_log_set_vprintf(&vprintf_into_spiffs);
  //install new logging function
  //trigger some text
  esp_log_level_set("TAG", ESP_LOG_DEBUG);
  //write into log
  esp_log_write(ESP_LOG_DEBUG, "TAG", "text!\n");

  delay(1000);
  WiFi.begin(ssid, password);
  delay(1000);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(1000);
    Serial.println("Connecting to WiFi..");
  }
 
  Serial.println("Connected to the WiFi network");
  Serial.println(WiFi.localIP());

  server.on("/events", HTTP_GET, [](AsyncWebServerRequest *request){
    if(SPIFFS.exists("/LOGS.txt")) {
      request->send(SPIFFS, "/LOGS.txt", "text/plain");
    } else {
      request->send(200, "text/plain", "LOGS not found ! Restarting in 5 seconds..");
      delay(5000);
      ESP.restart();
    }
    
    });

  server.begin();

  File file2 = SPIFFS.open("/LOGS.txt");

  if(!file2){
      Serial.println("Failed to open file for reading");
      return;
  }

  Serial.println("File Content:");

  while(file2.available()){

      Serial.write(file2.read());
  }

  file2.close();

  Serial.println("End of file content");
}

void loop() {
  if ((WiFi.status() == WL_CONNECTED)) { //Check the current connection status
 
    HTTPClient http;
 
    http.begin("http://jsonplaceholder.typicode.com/comments?id=10"); //Specify the URL
    int httpCode = http.GET();                                        //Make the request
 
    if (httpCode > 0) { //Check for the returning code
        Serial.println();
        Serial.printf("[HTTP] GET... code: %d\n", httpCode);
        if(httpCode == HTTP_CODE_OK) {
            String payload = http.getString();
            Serial.println(payload);
            Serial.println();
          }
      } else {
          Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
        }
 
    http.end(); //Free the resources
  }
 
  delay(10000);
 
}

And it outputs:

Connected to the WiFi network
192.168.1.107
File Content:
text!
text!
End of file content

So it ouputs text! twice…
Shouldn’t it output debug messages ?