You can easily configure this via SQL Server Configuration Manager:

enter image description here

by modifying the directory for the -e parameter, which controls the error log destination.

Default Log Folder: C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Log

You can of course just delete the files manually, but it sounds like you really want to reduce the number of logs used and/or reduce their size.

The steps contained in the above link detail how to do this in SQL Server Management Studio:

  1. In Object Explorer, expand the instance of SQL Server, expand Management, right-click SQL Server Logs, and then click Configure.
  2. In the Configure SQL Server Error Logs dialog box, choose from the following options.a. Log files countLimit the number of the error log files before they are recycledCheck to limit the number of error logs created before they are recycled. A new error log is created each time an instance of SQL Server is started. SQL Server retains backups of the previous six logs, unless you check this option, and specify a different maximum number of error log files below.Maximum number of error log filesSpecify the maximum number of archived error log files created before they are recycled. The default is 6, not including the current one. This value determines the number of previous backup logs that SQL Server retains before recycling them.b. Log file sizeMaximum size for error log file in KBYou can set the size amount of each file in KB. If you leave it at 0 the log size is unlimited.
enter image description here

How to clear error logs using query in SQL Server without restarting the instance?

Reference : How to Recycle SQL Server Error Log file without restarting SQL Server Service

Use [master];
GO

SP_CYCLE_ERRORLOG
GO

After run the command, please check: “C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Log” and delete old file (like: ERRORLOG.1, ERRORLOG.2 …). 

Sources:

https://dba.stackexchange.com/questions/253472/how-to-remove-sql-server-error-logs

https://stackoverflow.com/questions/41459371/how-to-clear-error-logs-using-query-in-sql-server-without-restarting-the-instanc

Last modified: January 29, 2024

Author

Comments

Write a Reply or Comment