IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
To store the audit log in an additional third-party storage, to send a notification, or just monitor the "logged" events, implement an IAuditLogger with its single Log method and register it in the container (a name is required):
ObjectFactory.Container.RegisterType<IAuditLogger, CustomAuditLogger>(
"CustomLogger"
);
For more details on implementation, refer to the ElasticsearchAuditLogger GitHub project.
ElasticsearchAuditLogger
NOTE: The Log method is called synchronously during event handling, which means that the time your logging takes is added to the overall operation time (for example, to publishing an item). Plan carefully the performance implications and if needed, introduce some asynchronicity in your code. Alternatively, introduce an out-of-process message queue or a logging agent to ensure the quick completion of the operation.
To implement audit for your custom events or for Sitefinity's events not implemented out-of-the-box, either construct an AuditInfo instance and the Log method of all registered loggers:
foreach
(var auditLogger
in
ObjectFactory.Container.ResolveAll<IAuditLogger>())
auditLogger.Log(auditInfo);
Alternatively, register an event handler along with the corresponding converters as demonstrated by the following code:
Event code
Global.asax
To augment the logged event information, for instance loading additional information, implement an IAuditInfoProcessor with its single Process method and register it the container (the name is required).
Following is an example code that adds the display name of the current user (first name and last name) to each log entry:
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important