factotum

Monday, March 05, 2007

Adding Logs to the Mac OS X Console

Console.app is a really nice, simple application that displays log files updated in real time. I often keep multiple terminal windows open with tail -f running on some log file to keep track of various applications. There are some nice advantages to using Console over tail:
  • filter output so only lines containing particular text (like ERROR) are displayed
  • insert a marker so you can see what was written after a certain point
  • clear the output
You can do all of these things with tail (combined with other utilities, like grep), but Console provides, I feel, a much nicer interface.

Console comes pre-configured to display logs in several standard locations. But if you install new applications like application or web servers, their logs may not be written to one of the standard locations.

The easiest way to add log files to Console is to symlink the directory they're in to one of the standard locations, which are:
  • /var/log
  • /Library/Logs
  • ~/Library/Logs
Of these, probably the best to modify is ~/Library/Logs, which contains log files specific to your user. However, it should be safe to add to any of these directories.

In my case, tomcat writes its logs to /Applications/jakarta-tomcat-5.0.28/logs. To get these logs to appear in Console:
  1. Open a Terminal window (/Applications/Terminal)
  2. Type ln -s /Applications/jakarta-tomcat-5.0.28/logs ~/Library/Logs/tomcat
  3. If Console is open, quit and re-open it.
Now, when you look in the Logs pane on the left side, you'll see a "tomcat" folder under the ~/Library/Logs folder, containing all of tomcat's log files.

Labels: