Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

How to write page.model.json (Jackson Exporter in sling model) response to request.log in AEM

Avatar

Level 2

Hi Team,

Our project is Remote SPA, the AEM page data is exposed by jackson exporter like content/my-site/us/en/sample-page.model.json. Each component is implemented by jackson exporter.


So I have a requirement of write each page.model.json request coming to AEM should be logged into logs/request.log.

 

Some details every sling model is implementing ComponentExporter (com.adobe.cq.export.json).

@arunpatidar 
Urgent requirement.

 

Thanking in advance

1 Accepted Solution

Avatar

Correct answer by
Level 5

First of all it may not be a good idea to log the entire json into your log file for every request that comes to publisher, but if you really intend to have it, one option is adding a sling filter that intercepts all requests with mode.json as selector.extension configuration, and as part of that filter you can log the entire json response. Hope this info helps. Thanks !

View solution in original post

5 Replies

Avatar

Community Advisor

Sorry I don't understand your question, I see the requests are being written in the request.log for the SPA remote as well, see below:

Esteban666_0-1689877188560.png

 



Esteban Bustamante

Avatar

Level 2

hi @EstebanBustamante , Thanks for your reply, In request.log  it won't print .model.json response, I want it to print page.model.json response.

Avatar

Community Advisor

If you see a network call to page.model.json then it should be logged in request.log.

Avatar

Correct answer by
Level 5

First of all it may not be a good idea to log the entire json into your log file for every request that comes to publisher, but if you really intend to have it, one option is adding a sling filter that intercepts all requests with mode.json as selector.extension configuration, and as part of that filter you can log the entire json response. Hope this info helps. Thanks !

Avatar

Level 2

Hi @mahi1729 , Thanks for your reply. Yes it is correct, We have implemented with Filter that it interscept every request. But it is client requirement as we have to implement it.