Clear log entry?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2015 04:35 PM
Hi folks
I have just been asked by my colleague who is experimenting Credit Card Regex test to find out records with credit card number pattern. The sys_log has been written for testing but he wonders if the logs can be cleared?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2015 01:00 AM
Hi George,
By default table syslog is a rotated table (System Definition -> Table Rotations) with a default configuration of 8 rotations, 7 days each. This means it only stores data for 56 days, and it's cleaned automatically.
Table Rotation - ServiceNow Wiki
If you really need to have the table cleaned now, you will probably have to open an incident to ServiceNow support.
Regards,
Sergiu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2015 01:15 AM
If it just for temporary purpose, you can open the delete ACL on syslog table and remove the 'nobody' role from 'Require Roles' related list. That should make the delete button visible. Add the 'nobody' role back to the ACL once done.
I am sure ServiceNow will not recommend doing it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2020 05:17 AM
Hi Kalaiarasan,
Thanks for the solution.
Actually, I tried by removing 'nobody' role from ACL. But after deleting logs, we can not add 'nobody' role again to that ACL.
Thanks,
Simran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-18-2015 04:58 AM
Hi George,
I did clear some log statements using background scripts in developer instance in past.
That worked perfect for me. But seriously I dont know the implications of performing this operation in live prod instance.
the code which I used was something like
var deleteObj = new GlideRecord('syslog');
var encodedQry = "Encoded query should go here";
deleteObj .addEncodedQuery(encodedQry);
deleteObj.query();
gs.print(deleteObj.getRowCount());Run this much of code only for 1st time to see how many records are returned for deletion purpose.Once you see that records are under control and only count matches to your encoded query filter, you can go on and delete those by using below code.
var deleteObj = new GlideRecord('syslog');
var encodedQry = "Encoded query should go here";
deleteObj .addEncodedQuery(encodedQry);
deleteObj.query();while(deleteObj.next()){deleteObj.deleteRecord();}Note: Please check if this has any cons using this operation.pradeepksharma, rfedoruk bernyalvarado Any comments are much appriciated.