Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Display realtime log files automatically' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Display realtime log files automatically
Authored by: jbc on May 26, '04 02:53:28PM

You might also be able to incorporate something like the setup I use for MkConsole. It's pretty flexible, so you could probably adapt the method to work with Terminal or Console somehow.

A shell script set as a login item -F tails all files in a folder of symlinks to log files I want to monitor (this works with GNU tail; not sure about the default tail). This gets redirected through a sed filter into a single log file that you can monitor for all the logs. That way you have only one log file to watch, and it follows new files when they're rotated. etc. Think it will automatically pick up a new file when it appears at the location referenced by the symlink.

#!/bin/sh
#login shell script
echo "" > /Library/Logs/monitor.log
GTAIL=/opt/local/bin/gtail
SED=/opt/local/bin/sed
$GTAIL -n 25 -F /Library/Logs/Monitor/* | $SED -u -f /Library/Logs/logfilter >> /Library/Logs/monitor.log

With the sed filter you can also reformat the main log file to make it more readable. Mine ends up looking something like this:

exim        2004-05-26 10:13:14 Start queue run: pid=328 -qqf
exim        2004-05-26 10:13:14 End queue run: pid=328 -qqf
system      May 26 10:13:14 asx ConsoleMessage: Starting network time synchronization
system      May 26 10:13:14 asx ntpdate[342]: ntpdate 4.1.1@1.786 Fri Sep 12 18:30:10 PDT 2003 (1)
system      May 26 10:13:14 asx set-hostname[352]: setting hostname to asx.local
console     May 26 10:13:16 asx automount[384]: automount version 57
system      May 26 10:13:15 asx ntpdate[342]: step time server 17.254.0.26 offset -0.301559 sec
system      May 26 10:13:15 asx ntpd[357]: ntpd 4.1.1@1.786 Fri Sep 12 18:30:03 PDT 2003 (1)
system      May 26 10:13:15 asx ntpd[357]: precision = 7 usec
system      May 26 10:13:16 asx ConsoleMessage: Starting network file system
exim        2004-05-26 10:14:13 HYBZVM-0000AV-5C <= ann5120-errors+1027853.896030489 ...
            P=esmtp S=34040 id=5.600.5.0.0.28327.1085589935@sender20.mail2.experian-ems.com
exim     *  2004-05-26 10:14:16 HYBZVM-0000AV-5C => Failed system filter checks - 0.9999990 ...
exim        2004-05-26 10:14:16 HYBZVM-0000AV-5C => cnn <cnn@localhost> R=local_domain T=local_smtp
exim        2004-05-26 10:14:16 HYBZVM-0000AV-5C Completed
cron        May 26 10:15:00 asx CRON[814]: (root) CMD (/opt/local/sbin/anacron -s)
cron        May 26 10:15:00 asx anacron[815]: Anacron 2.3 started on 2004-05-26
cron        May 26 10:15:00 asx anacron[815]: Normal exit (0 jobs run)
console     fetchmail: background fetchmail at 355 awakened.
ipfw     -  May 26 10:15:33 asx kernel: ipfw: 5000 Deny TCP 209.128.151.246:4056 ...

Makes it pretty easy to follow what's going on in a number of logs at once.



[ Reply to This | # ]