The "Execution log" section is very basic. If you ...
# suitescript
m
The "Execution log" section is very basic. If you wanted to make sure if an HTTP request reached a RESTlet endpoint or not, how do you answer that question?
s
one thing we commonly do to trace individual requests is to add a correlation id to each log message (automatically in our case)
m
but you can't search the logs, right?
s
yes you can. Look for Server Script Logs
m
I didn't know that, will do. Thanks very much.
s
there is also request logging on another page, but I don't use that often.
for SOAP requests it shows request/response. For RESTlets it doesn't as far as I recall
m
Will check. ❤️
s
We also use correlation ids in our Restlet request and logs as well. In fact, the first thing most of our restlets do is to log the request body or params, so we can see exactly what was sent with every request, and when (though we don’t do this for restlets that expect very large request payloads, though).
m
@scottvonduhn In that case, do you use an external service for log management?
s
no, we are just using the script logs within Netsuite, though you could write to a custom record type, file, or even external log service instead.
here’s our basic restlet template, with correlation id and request logging (using N/log)
For this to work, the client calling code needs to pass in a correlation id. But, you could also generate it within the restlet, probably using a UUID library, to have a unique id per restlet execution, too.
s
we just use a default random integer if we don't receive a correlationid from the caller, because in practice in such cases we need only identify uniqueness over a relatively short time period
s
any random number or string is probably good. Thankfully, it is a requirement that our calling clients must send correlation ids, so the instances where it is missing are rare (usually an indication that someone sent the request manually with Curl or Postman).
s
also, having a 4 or 5 digit integer prefix on log titles is easier on the eyes than UUIDs 🙂
1000 1
m
@scottvonduhn Thanks very much for sharing that template ❤️