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

Deepak,



If you need to delete million or records, using GlideRecord is not the fastest way.


If you don't need to full syslog shard (the active table from Rotations for syslog) then you can just ask ServiceNow to truncate it for you. It's much faster and no real performance impact on the production instance (but you will lose all records from the table).


If you need only to delete based on a particular criteria (like the encoded query) you can use GlideRecord deleteMultiple (GlideRecord - ServiceNow Wiki ), but again, if you have millions of records is not going to be very fast. Even so, impact over the instance should not be high.



Regards,


Sergiu


You can try below script   to delete all entries in the table, it's faster than using gliderecord



gs.sql('truncate <table>');



source:http://www.servicenowelite.com/blog/2014/2/14/deletion-methods


Keep in mind this is a production instance. Doing a gs.sql in a production instance is way too risky. If it's ever needed, It's better to leave this responsibility to the ServiceNow support team .



Thanks,


Berny


Thanks a lot Berny.   This is actually our non-prod environment, we might just forgo the log cleanning, however it good to know about the best time to use gs.log


bernyalvarado
Mega Sage

Hi George,



I hope you're doing great!



Perhaps one small thing to add to the list of great comments you already got is that it is a good idea to avoid doing any type of gs.log() on the server side scripts. Unless it's used temporarily for debugging in a development instance, it's better to avoid using log messages for various reasons like:



  a) ensure an agile troubleshooting process in production with only relevant log information


  b) avoid any type of performance degradation


  c) exposing any type of sensitive information



There may be few scenarios where it might make sense to keep logs message in production, specially for scenarios where there might be an issue that it can't be reproduced in other environment; still, these should be treated as a temporary measure until the root cause of the problem is understood.



It's also important to keep in mind that gs.log statements in the service side script will appear in the ServiceNow ACE report which audits the best practices applied in an implementation.



I hope this helps.



Thanks,


Berny