Sling Logs not capturing Content Fragment Logs | Community
Skip to main content
February 3, 2025
Solved

Sling Logs not capturing Content Fragment Logs

  • February 3, 2025
  • 4 replies
  • 1008 views

Enable automated logging when changes are made to the content fragments and the logs should include the AEM User, time, date & changes made. When I tried to create a custom log in sling loggers and provided the path but no loggers appeared. Can please suggest?

Best answer by EstebanBustamante

Hi,

OOTB AEM provides audit logs for assets; however, I’m not sure if this includes content fragments. You can find more information on the OOTB options here:


https://experienceleague.adobe.com/en/docs/experience-manager-65/content/sites/administering/operations/operations-audit-log#configure-dam-audit-log-purging
https://exadel.com/news/viewing-aem-audit-log-without-acs-commons/

 

If you need to create a log with more detailed information, you’ll need to write something custom. I don’t think simply attaching classes to a new logger will provide the desired output. Instead, you’ll need to implement a custom process for logging. One approach is to create a workflow launcher that listens for changes on your Content Fragment’s path and triggers a custom workflow to write the required log.

 

Here are some useful resources:

https://experienceleague.adobe.com/en/docs/experience-manager-65/content/sites/administering/operations/workflows-starting

https://experienceleague.adobe.com/en/docs/experience-manager-learn/forms/adaptive-forms/custom-process-step-aem-workflow

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/audit-log-with-extra-information/m-p/394919

 

 

Hope this helps!

4 replies

kautuk_sahni
Community Manager
Community Manager
February 3, 2025

@estebanbustamante@tarunkumar@kapil_rajoria@himanshu_jain@raja_reddy@veena1@chinmayish@sh1ju@preetpal_bindra@rahulmohan

Kindly take a moment to review this question and share your valuable insights. Your expertise would be greatly appreciated!

Kautuk Sahni
EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
February 3, 2025

Hi,

OOTB AEM provides audit logs for assets; however, I’m not sure if this includes content fragments. You can find more information on the OOTB options here:


https://experienceleague.adobe.com/en/docs/experience-manager-65/content/sites/administering/operations/operations-audit-log#configure-dam-audit-log-purging
https://exadel.com/news/viewing-aem-audit-log-without-acs-commons/

 

If you need to create a log with more detailed information, you’ll need to write something custom. I don’t think simply attaching classes to a new logger will provide the desired output. Instead, you’ll need to implement a custom process for logging. One approach is to create a workflow launcher that listens for changes on your Content Fragment’s path and triggers a custom workflow to write the required log.

 

Here are some useful resources:

https://experienceleague.adobe.com/en/docs/experience-manager-65/content/sites/administering/operations/workflows-starting

https://experienceleague.adobe.com/en/docs/experience-manager-learn/forms/adaptive-forms/custom-process-step-aem-workflow

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/audit-log-with-extra-information/m-p/394919

 

 

Hope this helps!

Esteban Bustamante
NivethaT1Author
February 4, 2025

Hi @estebanbustamante,

Thanks for your suggestion. I tried with the workflow approach

1. Created workflow process step, Model and Launcher

2. Added new entry in user mapping service amendment and provided necessary service to the user

I am able to log, which cf is modified, User, date & time but not able to log the changes made. I tried to hit the version history, eventhough there is multiple histories, getting error like no histories for the particular node. Can you please suggest?

 

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
February 4, 2025

Sorry @nivethat1, I missed the part where you mentioned that you need to be aware of the changes made. If that's the case, then the workflow approach won't provide what you need. However, you can still use a ResourceChangeListener to monitor the content fragment paths you need, or alternatively, you could use a SlingServlet to capture the values before updating. DO not use EventListener as this is deprecated. The filter approach might be a bit more complex, so explore the ResourceChangeListener first, here is a good example of what you need to do: https://techrevel.blog/2017/03/15/resourcechangelistener/ 

 

Additional Resources: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/clarification-eventlistener-eventhandler-and/td-p/608961

Sling Filter: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-log-monitor-user-activity-in-aem6/td-p/207402 

 

Hope this helps

Esteban Bustamante
aanchal-sikka
Community Advisor
Community Advisor
February 3, 2025

@nivethat1 

 

Out of Curious... What do you mean by automated logging?

Aanchal Sikka
kapil_rajoria
Community Advisor
Community Advisor
February 4, 2025

Hi @nivethat1 ,
For this "logging when changes are made to the content fragments and the logs should include the AEM User, time, date & changes made" you can go with the following options:
1. Create a custom event listener and use a logger in that file.
2. Create a custom workflow or sling job use a logger in that file.
In any of the above approach, you can check the logs output here: http://localhost:4502/system/console/slinglog or search it in the error.log file present inside crx-quickstart > logs
3. Use AEM Audit Logs or create an custom Audit log:

AEM provides built-in audit logging capabilities that can be configured to track changes to Content Fragments. In case you are creating a custom Audit log, you can use a logger in that file and use the same process stated above to see the logs.

Please let me know, in which file you put the logs along with its description.