Monday, June 17, 2024

Sitecore Custom Audit Logs Generation & move into NoSQL MongoDB Part - 1

 Hi All,

After talking with my senior recently, we came to the conclusion that, while modifications are recorded in Sitecore logs, we do not have access to all audit log details, which presents a common issue across nearly all projects. Because there are so many other entries, it is quite difficult to determine that. In addition, we can store data in SQL, although doing so may eventually cause storage problems due to the database's excessive growth in size, and freetext search is not supported.

Thus, we made the decision to address and attempt to resolve that issue. We separated it into two sections for that:

Part 1: To start, we keep audit logs in a unique folder containing only the audit logs. This way, we can locate all audit-related items in one location and potentially mitigate the problem.

 

Part 2: All custom log data can be transferred to the NoSQL database MongoDB, allowing for cloud storage and more convenient detailed searches for changes to individual items.

I so began my research for Part 1. I broke up my work into the following steps:

 

1. Custom logs must be made in a designated folder.

2. Include audit-related entries.

I really appreciated the blogs listed below during my investigation. Kindly peruse those blogs, as they will offer you a glimpse of my intended actions.

https://www.sitecorefundamentals.com/a-complete-code-sample-for-creating-your-own-custom-sitecore-log

https://sitecore.stackexchange.com/questions/2966/logging-changes-in-sitecore-8-1-made-by-content-authors

I modified it to meet our demands, and the result is our unique code, which is below:

Audit.cs

z.AuditInitial.config

This code functioned as intended and began generating bespoke audit logs after the corresponding dll was deployed into the website bin folder.

However, since our ultimate objective is to store in NoSQL MongoDB rather than txt files, we are aware that it will generate an excessive number of files on disk, potentially leading to a storage problem.

In the next part, we will explain how we can write custom code to move these audit logs to MongoDB.

I hope you enjoy this Sitecore blog. Stay tuned for more Sitecore related articles.

Till that happy Sitecoring :)

Please leave your comments or share this article if it’s useful for you.

No comments:

Post a Comment