-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to capture headers for HttpRequest #701
Comments
Hi @pankaj0509 - can you provide some more informaton on what you're logging? A sample of your code would be helpful. |
Hi @jongpie Thanks for your response . Actually I am using below code. Logger.info(methodName)
.setHttpResponseDetails(httpResponse)
.setHttpRequestDetails(httpRequest)
.setField(LogEntryEvent__e.Source_System__c, StringConstants.SALESFORCE_STRING)
.setField(LogEntryEvent__e.Destination_System__c, httpRequest.getEndpoint())
.setField(LogEntryEvent__e.Log_Type__c, StringConstants.OUTBOUND_RECORD_TYPE)
.setField(LogEntryEvent__e.Method_Name__c, methodName)
.setField(LogEntryEvent__e.Total_Callout_Duration__c, miliSecInInteger); You can see that I am using setHttpRequestDetails(HttpRequest). Here HttpRequest is having various headers .
once callout transaction is successful . I am getting log entries is generated as expected but when i see that request header information it is coming blank. |
Hi @pankaj0509 thanks for the info! The
So, the The only option that I can think of to work around this limitation is to add a method overload for HttpRequest httpRequest = new httpRequest();
httpRequest.setHeader('involved-party-id-type', 'CIF');
httpRequest.setHeader('involved-party-version', '7');
httpRequest.setHeader('Content-Type', 'application/json');
List<String> headersToLog = new List<String>{ 'involved-party-id-type', 'involved-party-version' };
// This would be a new method overload for setHttpRequestDetails()
Logger.info('some message').setHttpRequestDetails(httpRequest, headersToLog) So this would add a bit more work on your end (to build the list of header keys), but it would then give Nebula Logger enough context to store the |
@jongpie Do you mean we have to create following fields in logEntryEvent__e and logEntry__c object . and then we have to overload setHttpRequestDetails(httpRequest, headersToLog). need to create overload method in LogEntryEventBuilder class global LogEntryEventBuilder setHttpRequestDetails(System.HttpRequest request, List headerList) {
kindly advise if my understanding is correct |
@pankaj0509 yeah, your understanding is correct! And I think your sample code looks correct too. What do you think of this approach? |
This functionality is now available in release |
I wouldn't call it a complete solution, since the developer needs to manually list all the headers to be logged - some of which may be difficult to find, as they may be set elsewhere than in the code, for example in External Credentials. But it's the best we can have right now, unless Salesforce extends the @jongpie, do you think is it worth to keep this issue open (or a new one) as a reminder for a future improvement (if SF ever implements that missing method)? |
@TrangOul I agree, it's not exactly the solution I would prefer, but it's the best we can have right now. As far as re-opening this issue/making a new one, that's a great question - I prefer not to have open issues for this type of situation:
If/when Salesforce gives some kind of indication that they're planning to add a |
New Feature Summary
Hi Team,
I am trying to log callout log and i am able to see the log . It is working fine however I am seeing that there is no request header being populated in "RestRequestHeaderKeys__c" in logEtry__c object . Could you please suggest me . it is a bug or there is no such feature to collect request header information.
Pankaj
The text was updated successfully, but these errors were encountered: