Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Purge of SQL Server logs

Author  Topic 

sqlpal2007
Posting Yak Master

200 Posts

Posted - 2011-12-13 : 15:52:49
Hello All,

How can I trace when the SQL server logs are purged? Is there any trigger event or system sproc which I can run manually to purge the SQL Server logs and then record the date stamp for audits?

Thanks for help,

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-13 : 15:57:46
What SQL Server log are you referring to? And by purge, what do you mean?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sqlpal2007
Posting Yak Master

200 Posts

Posted - 2011-12-13 : 16:07:00
The auditors say they wanted to track the event when the SQL purges event logs. I have no idea what that means. My guess is neither do they.

How would you infer this Tara so I can propose auditors?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-13 : 16:15:46
I would suppose they are referring to cycling the error log. I suppose you could audit it by running xp_readerrorlog as cycling the error log gets logged in there. Not sure if there's a better way, a quick google on it didn't show anything good.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sqlpal2007
Posting Yak Master

200 Posts

Posted - 2011-12-13 : 21:47:30
Thanks Tara.I have a job which already captures falied login attempts using sp_readErrorLog. Also, I have created a SQL job automated to run every 1st day of the month to create a new error log file which calls sp_cycle_errorlog system sproc.

Do you think this sproc purges one oldest file before creating new one? If yes, how do I trace the purge event and dump it in audit table?

Please advice?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-13 : 22:50:40
Well it doesn't purge, it rolls it over. So it creates a new log file and archives the old one. Depending upon your settings, you will likely have several archive files. It's configurable.

The auditor is probably interested in this because you can cycle the error log multiple times to erase certain activities. So if you have your system configured to have 5 archive files, the malicious person could cycle the error log 6 times in a row.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

sqlpal2007
Posting Yak Master

200 Posts

Posted - 2011-12-13 : 23:41:56
By cycling the log multiple times how would I erase entries from there? Wouldn't the lod log gets archieved?
the auditors. So are u saying all the entires since the server was built are still there in one of the error log file..

I am still not clear on this.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-14 : 01:16:50
I am not saying that at all. Look at your error log directory. You'll see just a few archive files. They only go back a few reboots or a few cycling of the logs.

You can even open these up in SSMS to see what dates they go back to. If you reboot monthly like we do for MS security patches, you can only go back a few months. And if you cycle the logs, you can go back even less than that.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2011-12-14 : 09:03:57
quote:
Originally posted by sqlpal2007

By cycling the log multiple times how would I erase entries from there?


Lets say that your system is configured to keep the 5 most recent log files.

I do something malicious (which is recorded in the log file) then cycle the log file 6 times. You no longer have any trace of what I did ...

That may be what your auditors want protecting against.
Go to Top of Page

sqlpal2007
Posting Yak Master

200 Posts

Posted - 2011-12-14 : 09:11:50
Thanks guys.

I got it now. How do I capture recycling of log file? I have to dump the LogDate to a audit table for this event and design report so auditors can run it on demand.

Any idea?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-12-14 : 11:47:40
That's the part I'm not really sure of the best way to do it. If a log gets cycled, there is verbiage added to the new current log file as well as the old one. You mentioned you are cycling the logs on a regular basis, so you should be able to look at your system as an example.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -