How to get rid of old logs?

  • Hi,

    When I open the Log File Viewer in my Management Studio, I have to wait a long time before all the log lines in the "Current" log file (330K) are loaded. These logs go back to two months ago. Is it possible to shorten this range? For me a history of 1 month is more than enough.

    Second, I have Archives #1 - #6; is it possible to

    A) write them to a textfile just in case they are needed 15 years from now, and

    B) drop the Archive logfiles?

    Thanks,

    Raymond

  • you can use xp_readerrorlog / sp_readerrorlog and specify the parameters needed to only view the last month.

    you can configure the amount of logs that SQL stores in the archive but the minimum number is 6

    if you want to do a roll over of the log files every month, you can schedule a job which executes sp_cycle_errorlog, you will need to setup some kind of copy job which happens before that command to copy last error log, typically errorlog.6 and rename it to a timestamp (errorlog_20120515.log) if you wish to keep a set of logs. This will then increament the numbers of the remaining log files and start a new log file from scratch dropping the earliest error log.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply