All HowTo's Linux MySQL & MariaDB Redhat, Fedora and CentOS Linux Ubuntu, Mint & Debian Linux

Simple Rsyslog/MySQL Log Viewer in PHP

log-sc2I’ve previously documented how to configure Rsyslog to store logs in MySQL which gives a good tutorial on setting up MySQL as the Rsyslog backend and also remote logging to that Rsyslog server. To extend on that, you can easily view and filter the logs using the php web-app below. The code below requires PHP 5.4 of newer (may work on newer but not tested).

Download the web-app here in PHP.
(Updated to include SQL Injection prevention)

Download the file and change the name of it to something like “index.php”. It defaults to wanting access to the local MySQL server but you can point it to any MySQL server by editing the options sections.

$servername = "localhost";
$username = "sysloguser";
$password = "MySecretMySQLPassword";
$dbname = "Syslog";
$max_results = 200;
$logo = "https://agix.com.au/wp-content/uploads/2014/12/agix_black_1.png";
$title = "Log Filter Portal"; 

Thank you to Steve Simpson for your contribution.

Leave a Reply

Your email address will not be published. Required fields are marked *