Expand my Community achievements bar.

SOLVED

How to include protocal and request path in loggers

Avatar

Level 4

request.log file contains request(method,protocal) and response (status code,response time) details same way I want to see these details in my other custom log file. Is there any configuation I need to add ?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You can easily get those parameters from request.

As SlingHttpServletRequest is ServletRequest so it is having getProtocol() from ServletRequest. same way you can have other values as well from the request.

Hope this helps

Umesh Thakur

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

You can easily get those parameters from request.

As SlingHttpServletRequest is ServletRequest so it is having getProtocol() from ServletRequest. same way you can have other values as well from the request.

Hope this helps

Umesh Thakur

Avatar

Level 4

Hi @Umesh_Thakur 

Thanks for your info but my doubt is how we can add request URL and protocal to our custom log files.

EG:request.log file contains request(method,protocal) and response (status code,response time) details same way I want to see these details in my other custom log file. Is there any configuation I need to add ?

Avatar

Community Advisor

you will have your logger in your java file right?
there you will have these parameters from above explained methods and simply add those to the log level like info, debug etc.

but make sure you have enabled that logging level on system/console/slinglog console.

Hope this helps

Umesh Thakur

Avatar

Community Advisor

Hi @vijitha ,

As mentioned by @Umesh_Thakur  you can get easily using SlingHttpServletRequest   and after you got the value in the servlet then you can add those value into logger.

Please refer 

https://sling.apache.org/apidocs/sling11/org/apache/sling/api/SlingHttpServletRequest.html