Expand my Community achievements bar.

SOLVED

How to get request and response in other custom log file Eg:error.log

Avatar

Level 4

By default in request.log file will get request(method,protocal),response (status code,response time) and protocal details.If I  want to log same as request.log file in other custom log file(Ex:error.log). Is there any configuation I need to add ?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

I don't think that this is possible, because the request.log file is called via an abstraction (https://github.com/apache/sling-org-apache-sling-engine/blob/master/src/main/java/org/apache/sling/e...) at specific places in the sling engine process handling.

And you cannot register your code as a RequestLoggerService because that service interface is not public.

 

So this is not possible.

View solution in original post

6 Replies

Avatar

Community Advisor

Hi @vijitha ,

 

Could you please confirm what is the use case you want to achieve with another custom request log file? Though just try creating new log file using "log.request" logger type as slinglog.

 

Thanks,

Ritesh Mittal

Avatar

Level 4

usecase is to monitoring and to check site performance. we need to add request,response and protocal details to all custom log files in project.

Avatar

Community Advisor

You can't have the same classes bind to 2 different log files, so if you really need to put the request.log info into the error.log you could do it but I won't advise that, there is a reason why these two were split in the first place, so be careful if you really need to do this.

 

For merging the request.log into the error.log, you only have to add the "log.request" within the error.log definition. 

Esteban666_0-1686836480951.png

 

But I am curious why would you need this in the first place. It seems odd to me.

Here you can learn more about logging: 
https://www.baeldung.com/java-logging-intro

http://www.sgaemsolutions.com/2019/12/aem-logs-in-detail-part-2.html 

 



Esteban Bustamante

Avatar

Level 4

Hi @EstebanBustamante 

I don't to bind or merge those two. I need request,response details in my custom log file[PFA].

vijitha098_0-1686837339657.pngvijitha098_1-1686837727406.png

 

Avatar

Community Advisor

As explained, you cannot have that information in both files, you need to keep it in one, see my previous response about how to do it.



Esteban Bustamante

Avatar

Correct answer by
Employee Advisor

I don't think that this is possible, because the request.log file is called via an abstraction (https://github.com/apache/sling-org-apache-sling-engine/blob/master/src/main/java/org/apache/sling/e...) at specific places in the sling engine process handling.

And you cannot register your code as a RequestLoggerService because that service interface is not public.

 

So this is not possible.