I generally use google analytics, but occassionally I need to examine log files, for example to see how many 301 redirects from an old website are issued to real user-agents (rather than robots)
Can anyone recommend a good tool for doing ad hoc queries against log files?
Have you considered MS Log Parser 2.2? The price is certainly right :-)
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=24659
I recently started to use splunk Site Here. It is not an open source tool but has a free version for under 500MB indexed daily data. It is able to import apache log files very easily and can do many different kind of queries.
Other open source apache log file parsers are analog and webalizer, but I think that splunk is much better for what you needd