SQL CIS hardening doc for SQL server

Copper Contributor

Hi ,

As per the point 5.1 in CIS hardening doc for SQL server (Ensure 'Maximum number of error log files' is set to greater than or equal to '12' (Scored)) ,

 

We have increased the number of error log files, but i need guidance on what should i keep as their maximum size (in KBs) ?

 

SQL Version : 2017 Enterprise edition

 

 

arunakiri_0-1582690821632.png

 

 

1 Reply

Good day @arunakiri 

 

In first glance it sound like a question that related to third party company CIS and it is not related to this forum site.

 

From SQL Server there is no specific maximum size you should use for the error log files and each case should be examine according to your system. SQL Server Error Log file are initialized every time SQL Server Instance is started or you execute sp_cycle_errorlog. If you have 12 files then each time the log file is initialized a new file is created and old one removed. Hence, if SQL Server is not restarted and you do not execute sp_cycle_errorlog in a while then the error log file might grow very large.

 

Back to your question:

 

i need guidance on what should i keep as their maximum size (in KBs) ?


Like most questions the answer is: it depends. It depends on your system.

 

In most cases it is not common to limit the file size but the file time. For example it is more common to start new file each day (using a job for example that execute sp_cycle_errorlog). If you limit by file's size then it might be harder to follow the content since you do not know where look for it, but if you have a separate file each day or each week or each month (according to the amount of the is logged and the history you want to keep) then you have simple way to know where the data is stored by that period of time

 

If you do want to limit the size then you can use the following code In old version of SQL Server from SQL Server 2012 and later versions:

 

USE [master];
GO
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE',
    N'Software\Microsoft\MSSQLServer\MSSQLServer',
    N'ErrorLogSizeInKb', REG_DWORD, 5120;
GO

 

 

On new versions you can control the size directly in the SSMS Object explorer: Select Management -> Ritgh click on SQL Server Logs -> select Configure

 

f.png

 

Again, you will need to choose the size according to your system.