Auditing
Introduction
The process of auditing the Add, Change and Delete processes is based on the following events generated by the Mib repository:
- AfterCreate
- AfterDelete
- AfterSave
- BeforeDelete ⚠️
unused - BeforeSave ⚠️
unused
A Listener is required to process these events. To do this, we have provided two standard Listeners for you to use. They will be explained below.
How do I configure MibApi to log events?
Each time a record is changed (Add, Change or Delete), an event informing a Listener of the change is triggered. This Listener is responsible for persisting events. We currently have two standard listeners:
- MibEditHistoryListener
- MibEditHistoryListenerBatch
Every listener uses the MibObjectNotificationConfig for operation.
MibEditHistoryListener
Implements the IRepositoryNotificationListener interface responsible for providing the data needed to persist the audit event. Events are persisted individually with each save call (add, change, delete). This listener is available together with the EditHistoryMicroService project and needs it to work. see more about EditHistory
It is configured as follows:
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_NOTIFICATIONASSEMBLYNAME=MediaiBox.Cms.MicroServices.EditHistory.Listener
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_NOTIFICATIONCLASSFULLNAME=MediaiBox.Cms.MicroServices.EditHistory.Listener.MibEditHistoryListener
MibEditHistoryListenerBatch
Implements the RepositoryNotificationListenerBase abstract class responsible for providing the data needed to persist the audit event. This base class has batch persistence behavior. This listener is available together with the EditHistoryMicroService project and needs it to work. see more about EditHistory
It is configured as follows:
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_NOTIFICATIONASSEMBLYNAME=MediaiBox.Cms.MicroServices.EditHistory.Listener
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_NOTIFICATIONCLASSFULLNAME=MediaiBox.Cms.MicroServices.EditHistory.Listener.MibEditHistoryListenerBatch
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_MAXIMUMEVENTSTOBEPROCESS=10
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_INTERVALTOCOLLECTEVENTS=60
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_MAXIMUMPROCESSINGTIME=00:00:30
Can the listener be personalized?
Yes. To do this, you need to create a class that implements the IRepositoryNotificationListener (for persisting events as a unit) or the RepositoryNotificationListenerBase (for persisting events in batches). In the settings, simply enter your listener information: Example:
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_NOTIFICATIONASSEMBLYNAME=MyProject.Listener
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_NOTIFICATIONCLASSFULLNAME=MyProject.Listener.MyCustomListener
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_MAXIMUMEVENTSTOBEPROCESS=10
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_INTERVALTOCOLLECTEVENTS=60
MIBOBJECTNOTIFICATIONCONFIG_DEFAULT_MAXIMUMPROCESSINGTIME=00:00:30
For more information on how to view the events on the front, click here