join the MSSQLTips community

Today's Site Sponsor


 

Find performance issues related to Analysis Services memory limits.
 


Best Practice - Increase the Number of SQL Server Error Logs
Written By: Ashish Kumar Mehta -- 9/11/2009 -- 5 comments -- printer friendly -- become a member



…try SQL Backup pro for faster, smaller, more robust backups.

        Win SQL Books  -----  SharePoint Tips  -----  Live Webcast - SQL Backup Mistakes  -----  Bookmark and Share        

Problem
The SQL Server error log is a great place to find information about what is happening on your database server. Each SQL Server Error log will have all the information related to failures / errors that has occurred since SQL Server was last restarted or since the last time you have recycled the error logs. By default, there are six achieved SQL Server Error Logs along with the ERRORLOG which is currently used. However, it is a Best Practice to increase the number of SQL Server Error Logs from the default value of six. In this tip, you will see the steps which you need to follow to increase the number of SQL Server Error Logs.

Solution
By default, the error log is located at “Program Files\Microsoft SQL Server\MSSQL.n\MSSQL\LOG\ERRORLOG” and ERRORLOG.n files. A new error log is created when an instance of SQL Server is restarted. Also database administrators can run the DBCC ERRORLOG command or sp_cycle_errorlog system stored procedure to cycle the error log without recycling the instance of SQL Server. The most recent error log backup will have a name ERRORLOG.1, the second most recent error log backup will have the name as ERRORLOG.2 and the current error log will have the name ERRORLOG.

It is a BEST PRACTICE to increase the SQL Server Error Log from the default value of 6, because the error logs may contain critical information about your database server. As mentioned, by default there will be 7 error log files that exist, 6 archives and the current one.  When a new error log is created the oldest archive gets removed and that data is then lost forever.  So if you are trying to troubleshoot a system problem and are doing several restarts of SQL Server you may end up replacing all of your archives and then loose this valuable information in the error logs.


Steps to be followed to Increase the Number of SQL Server Error Logs in SQL Server 2008 / 2005

1. Connect to SQL Server 2008 or SQL Server 2005 Instance using SQL Server Management Studio

2. In the Object Explorer, Click on "Management" and expand "SQL Server Logs"

3. Right click SQL Server Logs and click on "Configure" option from the drop down list as shown in the below snippet.

 

4. This will open up Configure SQL Server Error Logs window as shown in the below snippet. Here, for Maximum number of error logs option you can specify a value between 6 and 99. In this example, I have changed the value from the default value of 6 to 10.

5. Once you have specified the new value for Maximum number of error log files click OK to save the changes.

 


As SQL Server Database Engine is not restarted frequently in a production environment, it will be a good practice for a DBA to schedule a SQL Server Agent Job which runs once in a day to execute either DBCC ERRORLOG or sp_cycle_errorlog system stored procedure to create a new SQL Server Error Log. It becomes easier to open up SQL Server Error Log file when it is small in size.

Next Steps:

  • To read SQL Server log files using T-SQL follow this tip.
  • Here is more information about sp_cycle_errorlog
Readers Who Read This Tip Also Read Comment or Ask Questions About This Tip Twitter This Tip!


 

Are you following DBA best practices?

Best practice #6: "Whenever possible, perform a daily full backup of all system and user databases."
Brad McGehee Expert DBA & Microsoft SQL Server MVP

   
Brad McGehee

Creating daily full backups is crucial, but often they take up too much time and disk space. SQL Backup enables you to compress your backups by up to 95% and lets you save valuable time and space that you can use for your daily full backups.

Download your free trial of SQL Backup now

 
SQL Backup logo
Red Gate Software - ingeniously simple tools

 

 



DB Nitro - SQL Nitro

SQL Nitro sits between SQL Server & its clients, optimizing the normally inefficient TDS protocol. Optimize TDS & compress the data up to 80%, reduce SQL bandwidth by 50%, & improve response times over 65%!

Download now!

More SQL Server Tools
SQL compliance manager

SQL Refactor

SQL Nitro

SQL Data Generator

SQL secure


Sponsor Information
Free SQL Server performance monitoring dashboard – Idera SQL check

Realistic test data in just one click with SQL Data Generator.

Wearing too many hats? We deliver valuable SQL Server consulting services for success.

Prepare for your next SQL Server interview with CareerQandA.com

Top 10 SQL Server Backup Mistakes and How to Avoid Them web cast by Greg Robidoux - February 10, 2010

All SQL Server, all the time! Sign-up for the MSSQLTips newsletter!

Just launched – MSSharePointTips.com...

Free Whitepaper - Streamline Backup & Recovery with LiteSpeed for SQL Server and LiteSpeed Engine for Oracle



Copyright (c) 2006-2010 Edgewood Solutions, LLC All rights reserved
privacy statement | disclaimer | copyright | advertise | write for mssqltips | feedback | about
Some names and products listed are the registered trademarks of their respective owners.