Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > General

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
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:

Code:
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:

Code:
table.log_table td {
     font-family: Trebuchet MS;
     font-size:8pt;
     border-width: 1px;
     padding: 1px 3px;
     border-style: solid;
     border-color: #ded;
     min-width:4em;
     }
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
Code:
# Log all the mail messages in one place.
mail.*                                                  -/var/log/maillog
with
Code:
mail.info;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 monitor_core_module.inc.php around line 1666 change


Code:
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'; }
	break;
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'; }
	break;
to
Code:
case 'log_mail_warn':
	$logfile = '/var/log/mail.warn'; 
	break;
case 'log_mail_err':
        $logfile = '/var/log/mail.err'; 
	break;
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
  #2  
Old 25th January 2012, 09:22
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

Time to revisit this!

I've just had to troubleshoot some mail problems and found the standard mail log presentation very poor. Having updated ISPConfig since my last look at mail problems, my changes had been lost.

I'm running on Centos, so for some strange reason ISPConfig decides to use/show the main maillog for warnings and errors.

Almost worse, because it shows the logs without replacing HTML entitities, the display of email addresses in the logs gets mangled.
example: some mail log messages show email addresses as
<john@example.com>
because of the bracketing ('<'..'>') webbrowsers will assume an unknown html tag and not show the content.

So as in the first post in this thread (with one small change) I recommend adding this to show_log.php
Code:
function log_to_table($datastring) {
  $data_lines = explode("\n", $datastring);
  $html = "<table class='log_table'>";
  foreach ($data_lines as $value) {
    $items = explode(' ',htmlentities($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 replace
Code:
$logData = nl2br($data);
with
Code:
$logData = log_to_table($data);
then follow the instructions for adding to the css
----------------------------
The second change was to ensure that the warnings and logs are in separate logs. /the instructions remainthe same as my original post except the changes to monitor_core_module.inc.php should now be made to monitor_tools.inc.php instead.

Last edited by mike_p; 25th January 2012 at 09:32.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ISPconfig is not processing apache logs: the web Traffic overview and stats are gone KingBeto General 12 15th January 2010 18:00
fail2ban Logs AdrianSmithUK Installation/Configuration 9 7th April 2009 14:07
help posting logs to forum and saslauth problem almeister9 HOWTO-Related Questions 3 19th September 2008 16:55
Apache Logs to MySQL Mosquito Technical 2 28th November 2007 16:14
Apache won't start: "Too many files error"? bpmee Server Operation 4 31st July 2007 13:37


All times are GMT +2. The time now is 02:32.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.