Search code examples
typo3

Best way to keep the TYPO3 sys_log nice & clean?


I have this MySQL

DELETE FROM sys_log 
WHERE sys_log.tstamp < UNIX_TIMESTAMP(ADDDATE(NOW(), INTERVAL -2 MONTH)) 
ORDER BY sys_log.tstamp ASC 
LIMIT 10000

Is this good for keeping the sys_log small, if I cronjob it?


Solution

  • Yes and No

    It IS NOT if you care about your record history. You can revert changes to records (content, pages etc.) using the sys_history table. The sys_history tables and sys_log tables are related. When you truncate sys_log, you also loose the ability to rollback any changes to the system. Your clients may not like that.

    It IS if you only care about the sys_log size. Truncating the table via cron is fine.

    In TYPO3 4.6 and up you can use the Table garbage collection scheduler task als pgampe says. For TYPO3 versions below 4.5 you can use the tablecleaner extension. If you remove all records from sys_log older than [N] days, you will also retain your record history for [N] days. That seems to be the best solution to me.

    And please try to fix what is filling your sys_log in the first place ;-)