Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Limit/rotate the visitor logs
Hi there.
An easy question, but one I couldn’t find an answer for. How do I set the TXP visitor log to rotate after a given time or number of entries?
I have a TXP site with referrer logging enabled on the visitor logs tab. I would like to limit this to the last 48hr or last x entries, primarily because my txp_log
table is larger than my textpattern
table (the txp_log
accounts for 40% of the total database size) and I like to keep my databases clean and tidy. I use Webalizer (updates daily) and tail
-ing of Apache logfiles, but I like the simplicity of TXP visitor logs…and short of disabling-then-enabling the logging there’s no easy way I can think of to cull the old referrer entries.
Thanks in advance for any suggestions.
Online
Re: Limit/rotate the visitor logs
gaekwad wrote:
How do I set the TXP visitor log to rotate after a given time or number of entries?
Hmmm, the trouble with the Advanced Pref setting for log rotation is that, from memory, the logs aren’t flushed until you manually look at the Visitor Logs page. That’s when the deletion occurs.
Thus, for a pure TXP solution you may need a (currently unwritten I think?) plugin to hook into the log_hit
callback. Then, every time a log entry is written to the table you can be notified and the plugin can trawl through the table and prune any entries that are greater than 48 hrs old (or based on the number of entries in the table). That’s how I’d approach it and the plugin is fairly trivial to write if PHP is your weapon of choice.
There might be another avenue to explore first though, so if anyone comes up with anything better then that’d be preferable. Failing that, gimme a shout and I can probably whip up a plugin for you.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Limit/rotate the visitor logs
Bloke wrote:
Hmmm, the trouble with the Advanced Pref setting for log rotation is that, from memory, the logs aren’t flushed until you manually look at the Visitor Logs page. That’s when the deletion occurs.
Thanks, Stef – so, if I understand this correctly, a TXP install that is left as-is for many years/iterations/etc — and the admin never logs in — will have an ever-increasing txp_log
size that won’t get shrunkified…that sounds a bit bad, in my humble.
Sadly, I’m not well-versed enough in PHP to bash out a plugin, though I have resolved to get my act together soon and be a more productive member of the TXP community:
http://www.43things.com/things/view/3368672/write-a-patch-andor-plugin-for-textpattern
…time will tell, no doubt :) Thanks for your offer of writing a plugin, but please don’t spend any time on this on my account, I was just curious if there was a setting that defined when the logs were cleaned/rotated etc.
Last edited by gaekwad (2011-04-11 09:17:35)
Online
Re: Limit/rotate the visitor logs
gaekwad wrote:
a TXP install that is left as-is for many years/iterations/etc — and the admin never logs in — will have an ever-increasing
txp_log
size that won’t get shrunkified…
From all my testing and code munching so far, that is my understanding. The log table is only flushed to the size specified in the Advanced Pref when you look at the logs on the admin side. And in light of Matts’ cool new plugin I wonder if that means your log table will never get pruned (I haven’t looked at the code so I don’t know for sure)?
It’s not ideal, but since we can’t rely on cron or some other timed script to be available in your hosting environment we need a physical ‘trigger’ to begin the deletion process. Visiting the logs is as good as any, albeit flawed for the reason you outline.
fwiw, I had a similar issue with smd_prognostics: I needed to choose what would trigger the plugin to look at your file system, and chose to offer you some options of where you wanted it to run.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Limit/rotate the visitor logs
Thanks, Stef – you actually answered my question without need for a plugin: I wasn’t aware of Logs expire after how many days? in Advanced Preferences, so I’ve now set that to two days.
I wasn’t being antagonistic when I referred to no log chomping as being ‘a bit bad’, it was just part of my understanding process. I’m more than happy to have the log culling being automated when I view the logs, given how often I spend in there…my query was more along the lines of ‘OMG why is my log table so huuuuge lol’ etc, which you answered for me. So, thanks :)
Online
Re: Limit/rotate the visitor logs
My plugin uses jquery to hide the Textpattern logs and therefore would not affect the cleanup process from happening when visiting that tab. I should probably add a recommendation that they be turned off though.
Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker
Offline
Re: Limit/rotate the visitor logs
I would rather like to know how to avoid your own ip being logged?
“Time you enjoy wasting, was not wasted.”
- John Lennon
Offline
Re: Limit/rotate the visitor logs
davidcrickett wrote:
I would rather like to know how to avoid your own ip being logged?
Rah_unlog_me plugin can do that.
Offline
Re: Limit/rotate the visitor logs
Thanks! :)
“Time you enjoy wasting, was not wasted.”
- John Lennon
Offline
Pages: 1