Posts tagged Error Logs

View SQL Server Error Logs through T-SQL

When SQL Server error log is not initialized at a regular interval causing the error log file to grow into a huge file. Viewing that in the SQL Log File Viewer would be a time consuming task. 

This article will show how to view the SQL Server error log from a query analyzer in 2000 or query editor in later versions. As an additional benefit this code filters the log file and displays only the past 24 hours (default code). 

To view SQL Server error logs in SQL Server 2000

To view SQL Server error logs in SQL Server 2005 / 2008

 

The script can be changed to display only data for the past n # of hours by changing the value of @Hours.

Bru Medishetty

Configuring the number of SQL Server Error Logs

SQL Server Error Logs; Introduction

By default, SQL Server maintains a minimum of 6 Error Log Files and each time the SQL Server is restarted, the Current Active Log File is recycled and new one maintained.

The Error Log Files are stored in the “Microsoft SQL Server\MSSQL.1\MSSQL\LOG\” Directory.

Monitoring the Error Log Files is very important since it displays vital information regarding the Server. Some of them are security related login information, Logins info such as Failure Logins or Failure and Success Logins etc are written based on the option chosen for the Instance. Other information reported includes Changes in Database Settings, Database backup related information; both successful backups and failures are reported.

Apart from those mentioned above, SQL Error Logs contains the useful info when a SQL Server does not start and what’s causing the failure to start.  There is a lot more information displayed in a SQL Server Error Log, a sample screen of what are the messages displayed upon SQL restart is displayed in the picture below.

Configuring Number of Error Logs

The default value of 6 Error Logs can be increased but cannot be decreases. To configure a higher number of Error Logs, follow the Steps as described below.

In the Object Explorer of SSMS, navigate to the Management Node and right click on SQL Server Logs and choose Configure as shown below.

A dialog box is displayed and the check box beside for Limiting the Number of error log files would be unchecked by default.

Check that and select the desired number of log files in the range between 6 and 99 and click the OK button (Not displayed in the Picture) to save the changes. A restart is not necessary for the changes to effective.

 – Bru Medishetty