Community discussions

MikroTik App
Topic Author
Posts: 44
Joined: Sun Apr 02, 2017 7:24 pm

PHP api real time logging /log/print

Tue Oct 05, 2021 12:37 am

Hi guys

i am trying to write a project, where it fetches all the data from the api via /log/print result.. and stores it on a table in php format.

i can output the log now.. but i would like to update it every 5seconds or so, so it could fetch utomaticaly the new logs, but i am kind of lost here..

this is the logging code php

if ($API->connect($mikrotik_ip, $mikrotik_username,$mikrotik_password)) {
	          $log = $API->comm("/log/print");
		   $clog = count($log);
		   $syslog = $log[$a]["message"]."<br>";
} ?>

then i am printing it on a PHP table
<div class="card-body">
                  <div class="table-responsive">
                    <table class="table table-striped table-sm">
                          <tr scope="row">
						  echo "<tr>";
						  echo "<td bgcolor=''></td>";
						  echo "<td>" . $syslog . "</td>"

output result


now i need it to update every 5 seconds.. but i am kind of lost http refresh? every 5 seconds? or via script? or is there any better option for real live logging from log/print console to output in php table or form?

Who is online

Users browsing this forum: No registered users and 7 guests