Monitor Log Using Console.app

When I’m working on a Linux desktop, I will frequently open a new shell window with tail -f on a log file I need to watch, such as my JBoss log. When I switched to my glorious Mac Pro I did the same thing, but it wasn’t exactly what I wanted.

I discovered that you can execute Console.app from the command line, so I have created a Bash alias that I run when I need to. Here’s what I put in my ~/.alias file:

alias jbtail='/Applications/Utilities/Console.app/Contents/MacOS/Console /opt/jboss/server/default/log/server.log &'

(Make certain all of that is on one line!) Obviously you should change the path to the log to be something you want to monitor. You can change the alias name to something else if you like. After editing the file, either logout or type . ./.alias (notice the dots) and that will load up the alias. Now you can type jbtail (or whatever you chose to call it) and Console.app will open for you watching changes to that log file.

What’s really nice about this method as opposed to just using Terminal.app is that Console.app remembers things like window geometry, fonts and, most importantly, which monitor it last ran on. This is really nice for people like me who have two monitors. I always want this log to show up on my second monitor, and once I’ve placed it there, future invocations of my alias will open it right where I left it.

If you already have a .bash_profile or .profile file in your home directory, look for a line that looks like this

test -r ~/.alias && . ~/.alias

If you see that, you’re all set. If not, adding it will ensure that your aliases get loaded when you next login. You could add the alias=... line directly to .profile or .bash_profile if you like, and skip the .alias file altogether. I have several aliases and I like to keep them in their own file.

Advertisements