Looking for a way to export script execution logs....
# dev-ops
d
Looking for a way to export script execution logs. In our production account it seems logs are rolled over every day. I wasn't sure if there was a pre-built solution or not, or if I should roll my own.
m
You can see historical logs by going to customization > scripting > script execution logs
d
thanks, I hadn't noticed that option before. It's always been a pain to search through execution logs, I was wanting a good way to export them into another system so that I could search through them better
I was thinking of an scheduled/external job to pull script execution logs out, maybe using the rest api with squiteql
and I haven't searched to see if there's an existing suitebundle that will export logs either
m
You can query them direclty via suiteql. If you don’t wan to write a script, you can use the tool I (SuiteQL Monaco Editor) or tim dietrich (SuiteQL Query Tool) wrote. Both are public bundles that have export capabilities to run suiteql queries. I don’t know how long logs stay queryable.
Copy code
SELECT
  log.date,
  log.type,
  scriptDeployment.title as deployment_title,
  log.title as log_title,
  log.scripttype,
  log.detail,
  scriptDeployment.scriptid as deployment_id,
FROM
  ScriptNote as log
  INNER JOIN scriptDeployment ON log.scriptType = scriptDeployment.script
ORDER BY
  log.date DESC
👍 2
slack bookmark 1
d
Thanks, I'll check those out. Our logs are only available for about a day
m
then a scheduled script that exports a file to csv may be your best bet if you want to see more
d
thanks again, this really helped me get set in the right direction. I ended up selecting from ScriptNote, Script WHERE ScriptNote.scripttype = Script.id I have a lot of scripts with multiple script deployments and was getting the same ScriptNote internal id for each script deployment.
m
Awesome! Happy to help
s
another alternative is to push the logs out to a centralized logging API rather than an external system pulling them.
d
I'd thought about that too, either way is fine. I'm leaning towards an external system to pull so that I can pull via rest api and use a suiteql query to join & format
@Matt Bernstein mentioned customization > scripting > script execution logs, which does hold logs for 30 days, but isn't very searchable. Otherwise script execution logs are
governed by a total storage limit on each instance of the NetSuite database. On each NetSuite server, if the database table that stores logs reaches this limit, all logs (across all customers on that server) are purged.
s
Aye, for the push approach I'd suspect a very similar SuiteQL query, just run with a script instead and pushing the results to an API. I guess the tradeoff is no external system needed but NS scripting isn't the most robust integration tool.
Whoah, @dbaghdanov just noticed that quote above - where did that originate? (the quote saying all customers on a server has logs purged)?
d
From the netsuite docs somewhere, wish I'd saved a link to it
our Prod logs are purged daily. Sandbox can go longer, several days to a week
s
Yes, I'd never seen the 'whole server purge' documented by NS but have suspected it for years.
d
Looks like those quotes were from Eric, quoting a help doc: https://stoic.software/effective-suitescript/14-all-logs/
s
Thanks @dbaghdanov - maybe I'll have to search NS help myself to confirm
e
Citation: NetSuite Help "Using the Script Execution Log Tab"
Important
The capacity for script execution logs on the Execution Log tab is shared by customers on the same database. For further protection against excessive logging, script execution logs are governed by a total storage limit on each instance of the NetSuite database. On each NetSuite server, if the database table that stores logs reaches this limit, all logs (across all customers on that server) are purged. This means that you may have logs up to 30 days if the volume is low, but you may have logs of less than a week if the log volume is extremely large. Use the Script Execution Log page for logs up to 30 days, regardless of volume. For more information about governance of script logs, see Governance on Script Logging
👍 1