Clear log entry?

georgechen
Kilo Guru

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,

9 REPLIES 9

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

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


Kalaiarasan Pus
Giga Sage

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.


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

Deepak Ingale1
Mega Sage

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.