I am designing an intranet system for medium business. Should I keep a single log table for all modules or make it separate?
Audit log keeps all admin/staff activities (create, update, delete objects) and the log structure is universal for any kind of module.
And also is it a good idea if I pull report based on log records? My log table keeps object type and object id so I could fetch data for any object and at any time based on event, object name and object id.
What is the best approach for reporting in such cases?
Well, when you go to review your logs, which would you rather do, look in one place where you can see everything or have to check several different places, each of which just shows one piece of the system in isolation?
Keep in mind that, with a single table, it’s trivial to filter out entries which are irrelevant or which the user does not have authorization to view. Combining several individual logs into a single, comprehensive view is a bit trickier to do, plus it has the additional disadvantage of, under most designs, requiring you to revisit the code which does the combining each time a new log table is added.
I definitely say a single log is preferable. The only situation I can think of where multiple segregated logs would be appropriate would be if security concerns were strong enough to require that log entries with different visibility must be physically segregated – and, in such a case, you’d probably be looking at separate log servers, not just separate tables.