We have a logging system built into our apps that logs data into a sql database
by default it only logs errors and other forced logs but with configurations it can be set to log all debug messages, all database transactions etc
we override for example all transactional commands like begin_transaction, end_transaction, reread, unlock, lock, same for DD operations such as request_save, request_delete etc
they all log before and after so you can time for example how long it took to do a transaction or a request_save.
in addition we add logging to all important operations as we create the app.
the log contains, user name, machine name, date time stamp, log type (info, error, debug, etc), source, line number, error number, log message etc
this allows us to quickly enable fine grained debug logging with a switch in the apps config file to debug locking issues, performance issues etc.