TweetFollow Us on Twitter

Tips & Tidbits

Volume Number: 21 (2005)
Issue Number: 9
Column Tag: Programming

Tips & Tidbits

Centralized Device Logging With Tiger and Syslogd

by Aaron Adams

Many network devices, such as routers, firewalls, and wireless access points, have the ability to send logging information to other listening devices called syslog servers. Mac OS X uses a syslog server daemon to record its own logging information, and that same daemon can also be configured to accept logging information from external devices. In this quick tutorial, we'll do just that by editing a text file, and using a new Tiger feature.

With Tiger, syslogd is initiated upon system startup by launchd, a new Apple daemon that manages the instantiation of other daemons and processes. System daemons are launched with the aid of a plist, an XML text file, placed in /System/Library/LaunchDaemons, and a file in that folder, named com.apple.syslogd.plist, is what we must edit to enable external logging functionality.

It's probably simplest to edit this plist in the Terminal. Backing up this plist file before editing it is a good idea, so start up Terminal and enter this line at the prompt:

cp /System/Library/LaunchDaemons/com.apple.syslogd.plist ~/Desktop/

For those unfamiliar with the Terminal, this command copies the plist file to the desktop for temporary safekeeping. The command to restore the file back to its original state is inversely thus:

sudo cp ~/Desktop/com.apple.syslogd.plist /System/Library/LaunchDaemons/

Next, we proceed to edit the plist:

sudo nano /System/Library/LaunchDaemons/com.apple.syslogd.plist

This line starts up the text editor nano as the root user to edit the plist file mentioned above. Scroll down to this line:

<string>/usr/sbin/syslogd</string>

...and add the following directly below it:

<string>-u</string>

Save and exit. The -u we've inserted is a switch at the end of the syslogd command that tells the process to listen on UDP port 514. Now that syslogd is ready to receive logging messages from other devices, we have to stop the current running syslogd process and restart it with the new option to listen.

sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist sudo
launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist

launchctl is a utility that instructs launchd to load and unload daemons, among other things. To verify that syslogd is receiving logging messages from external devices, we can watch the system log in action with this command:

tail -f /var/log/system.log

The last screen-full of the syslog will be displayed. When new events are received by syslogd, they'll be displayed on the screen and written to the log. Control-c will terminate the syslog watch.

That was easy! Well... wait for it... there's a catch. (You knew that, didn't you?) As of 10.4.1, there is a bug of some kind that affects syslogd. Each day in the wee hours of the morning, your Mac runs a script called /etc/periodic/daily/500.daily. Near the end of that script, the syslogd process is killed using the old-fashioned Unix kill command and when it restarts, for whatever reason, syslogd simply ceases to function. Not only does it not pay attention to log messages sent from other devices, it doesn't bother to record logging information from the local machine.

Fortunately, there's a simple fix. Also near the end of 500.daily, there is a command to call up another file named /etc/daily.local. This file is intended to execute additional commands for specific machines on a daily basis, and it may or may not already exist on your Mac. Either way, let's edit (or create) it with the following command in the terminal:

sudo nano /etc/daily.local

The contents of this file are pretty simple.

launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
sleep 1
launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist

Save and exit. This script stops and restarts the syslogd process via launchd so that it once again will listen for external logging messages. This script differs just a bit from the commands we used at the terminal. Since 500.daily runs as root and calls up daily.local, daily.local also runs as root, so the sudo command is not needed for launchctl. Also, we've inserted a sleep command to give the computer a second to catch its breath.

Finally, the daily.local script needs to be made executable with the following command:

sudo chmod 744 /etc/daily.local

That's it. Done. You are now logging away. Good job.


 
AAPL
$459.68
Apple Inc.
+4.56
MSFT
$30.24
Microsoft Corpora
+0.29
GOOG
$596.33
Google Inc.
+11.22
MacTech Search:
Community Search:

Reckless Racing 2 Review
Reckless Racing 2 Review By Greg Dawson on February 3rd, 2012 Our Rating: :: RUBBIN' AND RACIN'iPhone App - Designed for the iPhone, compatible with the iPad The original Reckless Racing game set the bar for down and dirty iOS... | Read more »
Five For Friday: Week of February 3
Another week has left us behind along with the first month of the year. As always with the arrival of Friday, we take a few moments to round up five of the most interesting apps and games that we’ve yet to cover in a more extensive form. There will... | Read more »
GHOST TRICK: Phantom Detective Review
GHOST TRICK: Phantom Detective Review By Dan Lee on February 3rd, 2012 Our Rating: :: TRICKYUniversal App - Designed for iPhone and iPad Use “Ghost Tricks” to possess objects and solve a murder.   | Read more »
Launch Center Launches New Third Party A...
Launch Center has gotten a major new update that brings new automatic app detection. While the app launched with support for built-in notifications, now the app supports launching third-party apps with specific commands, that can be scheduled to... | Read more »
Spy Mouse Feels the Love With New Valent...
EA and Firemint’s Spy Mouse has an update out now that’s designed to be more appropriate for this time of year, with Valentine’s Day coming up. Love is in the air, and while the cats in Agent Squeek’s life are still out to keep him from getting his... | Read more »
Panorama 360 Camera Review
Panorama 360 Camera Review By Jennifer Allen on February 2nd, 2012 Our Rating: :: CREATIVEUniversal App - Designed for iPhone and iPad Creating a panoramic image just got a whole lot simpler.   | Read more »
Gravity Lander Review
Gravity Lander Review By Rob Rich on February 2nd, 2012 Our Rating: :: SHORT FLIGHTiPhone App - Designed for the iPhone, compatible with the iPad Get three cosmonauts to land on the surface of Mars safely. It’s significantly harder... | Read more »

Price Scanner via MacPrices.net

27″ iMacs on sale for up to $130 off MSRP
  Apple resellers have 27″ iMacs on sale for up to $130 off MSRP. The following is a roundup of the lowest sale prices we’ve seen from Apple Authorized Internet/Catalog Resellers that are available... Read more
Updated MacBook Price Trackers
We’ve updated our MacBook Price Trackers with the latest information on prices, bundles, and availability from Apple’s authorized internet/catalog resellers: 17″ MacBook Pro 15″ MacBook Pro 13″... Read more
Refurbished Apple iPad 2s available for $100 off n...
 The Apple Store has Apple Certified Refurbished iPad 2s available for up to $100 off MSRP. Apple’s one-year warranty is included with each model, and shipping is free (for the most part, Apple... Read more
Apple offers refurbished MacBook Airs for up to $2...
The Apple Store is now offering Apple Certified Refurbished 2011 MacBook AIrs for up to $250 off the cost of new models. An Apple one-year warranty is included with each model, and shipping is free... Read more
Today only! 27″ Apple Thunderbolt Display for $100...
MacConnection has the 27″ Apple Thunderbolt Cinema Display on sale for today only for $899.99 including free shipping. That’s $100 off MSRP, and it’s the lowest price we’ve seen for this model from... Read more
15″ 2.4GHz MacBook Pro on sale for $175 off MSRP,...
Adorama has the 15″ 2.4GHz MacBook Pro on sale for $2024 including free shipping plus NY & NJ sales tax only. Their price is $175 off MSRP, and it’s the lowest price available for this model from... Read more
8GB iPod touch on sale for $20 off, includes free...
Amazon.com has lowered their price on the Black 8GB iPod touch to $179.99 including free shipping. Their price is $20 off MSRP, and it’s currently the lowest price available for this model from any... Read more
Open-box special: 13″ 256GB MacBook Air for $283 o...
MacMall has restocked open-box return 13″ 256GB MacBook Airs for $1316.16 including free FedEx shipping. Their price is $283 off the price of unopened boxes. Apple’s one year warranty and all... Read more

Jobs Board

Windows Mac Support Technician at Keystr...
at Beverly Hills, CA Mac Support Responsibilities: Support Apple product environment Administer Mac hardware Apply ... tickets Evaluate, test & propose new technologies for the Mac environment... Read more
On-Site Systems Support - Linux/Mac Tech...
XP, current MAC OSX and Microsoft Office 2007, Office 2008 (MAC), Microsoft Entourage and Outlook 2007 Knowledge of PC ... 2007, Office 2008 for Mac, Windows 98/NT/2000/XP/7, Current Mac O/S,VERITAS... Read more
MAC Systems Management Administrator at...
Available Ref ID: 1001703121 Visit Us www.technisource.com MAC Systems Management Administrator JOB DESCRIPTION MAC ... decision-making abilities Strong knowledge of current Apple Mac OSX and other... Read more
Software Engineering Manager - *Apple*...
Job Title: Software Engineering Manager - Apple TV Profession: Computer Engineering and Information Technology -> Technology Management Requisition Number 9439460Job Read more
Mobility Specialist - Apple Online Store...
Comfortable working with ambiguity; Experience with both Mac & PC. Previous experience working in a fast-paced ... product features and related accessories; Understand Apple's Digital Lifestyle... Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.