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:

Saturday, November 18, 2006

Importing an existing project to Subversion

I am a cvs user, but recently decided to check out subversion, which I'm using for some personal projects. The biggest challenge I ran into was just figuring out how to get my project set up the way I wanted. The documentation I could find was either too general, or took an approach I didn't like. So here's my quick guide to setting up a new subversion project for an existing codebase. This guide assumes the following:

1) You already have created your repository
2) For the purpose of the examples, I access my repository using webdav, and my repository is at http://localhost:8080/svn

The biggest difference between subversion and cvs in my eyes is how branches and tags are stored. In subversion, branched or tagged code exists in a separate directory hierarchy from the trunk. So a project's base directory generally has three directories under it: trunk, branches, and tags. The code goes in the trunk directory, and gets copied into the other directories when you branch or tag it.

For the purposes of this example, here's what my project layout looks like:

/home/project
/home/project/config
/home/project/docs
/home/project/source

I want "project" to be the name of my project, so I will browse to it at http://localhost:8080/svn/project. But I don't want the trunk, branches, or tags directories in my checkout location, as they just exist for subversion's benefit. Why subversion doesn't just create them for you and make their existence invisible, I don't know. I wish it did. But it doesn't, and you need to manually create them. The easiest way to do that is to create an import template in a temporary directory:

mkdir /tmp/import
mkdir /tmp/import/project
mkdir /tmp/import/project/trunk
mkdir /tmp/import/project/branches
mkdir /tmp/import/project/tags

Now, go into your temporary directory and import the template to create the project in subversion:

cd /tmp/import
svn import . http://localhost:8080/svn -m "initial checkin"

Now that my project template has been imported, I can go to my actual project directory and do a checkout there to get it under revision control:

cd /home/project
svn co http://localhost:8080/svn/project/trunk .

Now whatever I add from my project directory will get added under project/trunk in the subversion repository. I can start adding my directories:

svn add config/ docs/ source/
svn commit -m "added"

Now my project is created, and I can browse to my source files in the repository at http://localhost:8080/svn/project/trunk/source.

Labels: ,

Thursday, February 16, 2006

Are Power-Law and Normal-Distribution Problems Mutually Exclusive?

Once again, Malcom Gladwell has written an excellent analysis of a social problem and offered up a unique take on the issue. However, he seems to suggest that problems with a normal distribution and those with a power-law distribution (and the solutions to those problems) are mutually exclusive. He says "Power-law problems leave us with an unpleasant choice. We can be true to our principles or we can fix the problem. We cannot do both."

It seems to me that problems have power-law distributions when the solutions to the normal-distribution part of the problem are effective. A small minority of cars are gross polluters because the pollution control laws have been effective in getting carmakers to make cleaner cars and car owners to better maintain them. Presumably, only a small number of police use excessive force because the institutional controls and consequences are effective in deterring abuses by the "broad middle." And isn't it possible that the reason the majority of homeless people are only on the streets a day or two is because the shelters, soup kitchens, and other social services aimed at the broad middle are effective? If we removed those services, might we end up with a normal-distribution problem?

I would argue that the real solution to these problems lies in applying both the normal-distribution and the power-law solutions. Focusing simply on one aspect of these problems will only result in exacerbating the other.