View Single Post
Old 17th February 2011, 19:23
mike_p mike_p is offline
Senior Member
Join Date: Mar 2010
Location: Surrey, England
Posts: 140
Thanks: 9
Thanked 28 Times in 17 Posts
Default More on presentation of logs ...

1/ Formatting logs.

I think we can improve on the 'raw' display of logs, so I've been experimenting with better formatting.

I've written a simple function to go in the show_log.php script that converts the data into an html table:

function log_to_table($datastring) {
  $data_lines = explode("\n", $datastring);
  $html = "<table class='log_table'>";
  foreach ($data_lines as $value) {
    $items = explode(' ',$value,6);
    $html .= "<tr>";
    $html .= "<td>$items[0] $items[1]</td>"; //date
    $html .= "<td>$items[2]</td>"; //time
    $html .= "<td>$items[3]</td>"; //server
    $html .= "<td>$items[4]</td>"; //user
    $html .= "<td>$items[5]</td>"; //data
    $html .= "<tr>";
  $html .= "</table>";
  return $html;
then I replace the nl2br function with log_to_table.

After that we need a little tidying up with the css. In my test I use:

table.log_table td {
     font-family: Trebuchet MS;
     border-width: 1px;
     padding: 1px 3px;
     border-style: solid;
     border-color: #ded;
Conceptually I'm not sure where it should be placed. In my case I've added it to the end of content.css.

2/ In Redhat[Centos] and Gentoo distributions the maillog, mail error and mail warning logs all show the content of maillog.

I propose we split the logs.

1. Edit /etc/syslog.conf replace
# Log all the mail messages in one place.
mail.*                                                  -/var/log/maillog
Code:;mail.!warn    /var/log/maillog
mail.warn;mail.!err     /var/log/mail.warn
mail.err        /var/log/mail.err
then restart syslog with /etc/init.d/syslog restart

2/ Adjust ISPConfig to use the new error and warning logs:
Edit around line 1666 change

case 'log_mail_warn':
	if($dist == 'debian') { $logfile = '/var/log/mail.warn'; }
	elseif($dist == 'redhat') { $logfile = '/var/log/maillog'; }
	elseif($dist == 'suse') { $logfile = '/var/log/mail.warn'; }
	elseif($dist == 'gentoo') { $logfile = '/var/log/maillog'; }
case 'log_mail_err':
        if($dist == 'debian') { $logfile = '/var/log/mail.err'; }
        elseif($dist == 'redhat') { $logfile = '/var/log/maillog'; }
        elseif($dist == 'suse') { $logfile = '/var/log/mail.err'; }
	elseif($dist == 'gentoo') { $logfile = '/var/log/maillog'; }
case 'log_mail_warn':
	$logfile = '/var/log/mail.warn'; 
case 'log_mail_err':
        $logfile = '/var/log/mail.err'; 
I've tested in Centos, can't be sure of Gentoo.

Might also need to have a play with "logrotate".

Anyone interested in this being incorporated into the next release?

Last edited by mike_p; 17th February 2011 at 19:35.
Reply With Quote
Sponsored Links