filemtime($b)) ? $a : $b; // En son oluşturulan dosyayı bul }); $logs = file($latestLogFile); // En son log dosyasını oku $logs = array_reverse($logs); // Logları ters çevir $logArray = []; // Log dizisini oluştur foreach ($logs as $log) { preg_match('/\[(.*?)\] (.*?): (.*)/', $log, $matches); // Log formatını ayıkla if (count($matches) === 4) { $logArray[] = [ 'date' => $matches[1], // Tarih 'level' => $matches[2], // Log türü 'message' => $matches[3] // Log metni ]; } } echo json_encode_tr($logArray); // Log dizisini JSON formatında döndür