Question: I need to implement an audit trail for Add/Edit/Delete on my objects,I'm using an ORM (XPO) for defining my objects etc. I implemented an audit trail object that is triggered on 

1. OnSaving
2. OnDeleting

Of the base object, and I store the changes in Audit-AuditTrail (Mast-Det) table, for field changes. etc. using some method services called.

How do you implement audit trail in you OOP code? Please share your insights? Any patterns etc? Best practices etc? Another thing is that how to disable audit when running unit test,since I don't need to audit them but since base object has the code.

Changes to object (edit/add/del) and what field changes need to be audited

Answer: 
I don't know if it will fit seamlessly with your ORM, but i used [Point-in-Time](http://www.simple-talk.com/sql/database-administration/database-design-a-point-in-time-architecture/) database design for an ERP application and really recommend it. You automatically get History and Audit from this architecture, as well as other benefits.
I come more from the SW side that the DB side, if you create a set of DAOs (Data access objects) that you use for your interaction with the database. I would then insert the audit functionality into the respective functions in the DAOs that need to be trailed.

The database trigger solution is also feasible, it depends where you like to put your functionality, in the DB or in the code

There are a lot of ORM (Object relational Mapping) tools out there that create the DAO layer for you.