This is a basic solution.
Here is your html and js index.php
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Read Log File</title>
</head>
<body>
<div>
<ul id="log">
</ul>
</div>
<script src="./jquery-3.2.1.min.js"></script>
<script>
$(function(){
setInterval(function(){
$.getJSON( "./getLog.php", function( data ) {
var $log = $('#log');
$.each( data, function( key, val ) {
$log.prepend( "<li>" + val + "</li>" );
});
});
},5000);
});
</script>
</body>
</html>
Here is your php file getLog.php
<?php
session_start();
$file = '/path/to/your/file_log';
$total_lines = shell_exec('cat ' . escapeshellarg($file) . ' | wc -l');
if(isset($_SESSION['current_line']) && $_SESSION['current_line'] < $total_lines){
$lines = shell_exec('tail -n' . ($total_lines - $_SESSION['current_line']) . ' ' . escapeshellarg($file));
} else if(!isset($_SESSION['current_line'])){
$lines = shell_exec('tail -n100 ' . escapeshellarg($file));
}
$_SESSION['current_line'] = $total_lines;
$lines_array = array_filter(preg_split('#[\r\n]+#', trim($lines)));
if(count($lines_array)){
echo json_encode($lines_array);
}
?>