I use Catalyst (MVC framework for Perl), but the question probably apply to all MVC framework.
Until now, I used the Apache log files to get statistics about the visitors: user agent, URL accessed, time, etc. But now that I moved to an MVC framework, I don’t think this is adequate. If a request to /1/foo and /1/bar are the same for me, I want to show /1/ in my log only, for example.
So I am wondering what is the best way to generate my own log files for statistics. Should I treat it as just another log file in my application?
These statistics can be logged at any time. Ideally they would be logged after the page is sent to the user, so it will not feel the additional time required for logging.
Given that Catalyst already uses subroutine attributes liberally, one useful approach might be to use an attribute to wrap the relevant subs in a custom logging mechanism. I wrote an article about this technique which uses logging as an example. The basic idea is: