Community discussions

MikroTik App
 
PortalNET
Member Candidate
Member Candidate
Topic Author
Posts: 126
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);
		   $a=0;
		   $a<=$clog;
		   $a++;
		   $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">
                      <thead>
                        <tr>
                          <th>#</th>
                          <th>Log</th>
                          
                        </tr>
                      </thead>
                      <tbody>
                       
                          <tr scope="row">
                          <?php 
						  echo "<tr>";
						  echo "<td bgcolor=''></td>";
						  echo "<td>" . $syslog . "</td>"
						  ?>
                       
						
                       
                      </tbody>
                    </table>
                  </div>
                </div>

output result

Image

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: ko00000000001 and 20 guests