Understanding How to Check MS SQL Error Log Files

Summary: In MS SQL, transaction logs play an important role in keeping a record of the modifications in the database. However, sometimes these logs encounter SQL Server Error that interrupt the routines. Logs are great for troubleshooting SQL issues, but what if these logs only require troubleshooting? So, to help you with it, this blog provides a detailed guide to reading, analysing, and finding the location of SQL Server Error Log file. Along with that, it provides a DatabaseFileRecovery SQL Log Recovery Tool to handle log errors with confidence.  Download Now Purchase Now

About the MS SQL Error Log

Before proceeding to find out how to check these log errors, one must know what it is. These SQL Server Log files are plain text data files that maintain a record of several server-level issues. These are the start and shutdown process, deadlock, login tries, hardware and software failures, backup and restoration, etc. These are extremely useful to diagnose the problems and audit the activities of the SQL Server. 

Let’s find why it is necessary to check MS SQL error log file. The reasons are as follows:

  • Helps to detect the performance highs, issues, and failures.
  • To detect login attempts that failed and the security risks and threats.
  • Investigate configuration problems and SQL query errors.
  •  To prevent major SQL Server outages before they impact production.

What is the MS SQL Server Error Log Location?

By default, the SQL log file path is C:\Program Files\Microsoft SQL Server\MSSQLXX.MSSQLSERVER\MSSQL\Log

(Replace MSSQLXX with the version, like MSSQL15)

How to Open and Read SQL Error Logs?

There are different ways through which you can access and check the error logs in MS SQL Server. These are described as follows:

Method 1: Microsoft SQL Server Logs Error Test with SSMS

  1. Run the SQL Server Management Studio on your Windows and connect to the database instance.
  2. Then, move to the Management tab in the tree structure and click SQL Server Logs.
  3. Further, right-click on any log file there and press View SQL Server Logs.
  4. Finally, use it to filter the data according to different criteria. 

Method 2: Read MS SQL Server Error Log by T-SQL

  1. First, run the given command to view the latest entries.
USE MASTER GO EXEC dbfr.xp_readerrorlog; 0, 1, N’Logging SQL Server messages’, NULL,  NULL, NULL GO
  1. Next, run the DBFR xp_readerrorlog 1; — 1 = previous log command for a specific file.
  2. In the end, for the log search, use the command DBFR xp_readerrorlog 0, 1, N’backup’;

Method 3: Windows Explorer to Check MS SQL Error Log File 

  1. In your File Explorer on Windows, move to the log directory path.
  2. There, locate the ERRORLOG file and then, open it with the Notepad application.
  3. After that, press Ctrl + F, and the Find dialog box opens up.
  4. Finally, type keywords such as error, fail, or warning to find the log entries.

Method 4: SQL Server Error Log Location via Configuration Manager

  1. Open SQL Configuration Manager and move to SQL Server Services in it.
  2. Further, right-click your SQL instance and open Properties.
  3. Then, move to the Security Parameters tab and look Existing Parameters.
  4. Among them, one of the parameters represents ERRORLOGS.

With the above-given ways, read error log files in SQL Server. But what if you encounter issues with log files? 

Automatically Troubleshoot MS SQL Server Log Error

If you face issues with the transaction log file of your SQL Server, then use the professional SQL Log Recovery Tool. This utility is built with an easy-to-use GUI to repair SQL LDF and MDF files from damage or corruption. It has several recovery options with advanced features and keeps the data intact in a systematic order. Additionally, the tool has no size limitations and can be beneficial when you need to Shrink Log File in SQL Server. Moreover, it also helps save the data after recovery on all Windows OS. 

Tool Guide to Fix MS SQL Server Error Log

  1. Run the SQL Server Log Recovery Tool on your Windows computer.
  2. Then, click on (…) to add the SQL log LDF and MDF files from the PC.
  3. Press Next and preview the tables in the files. Select those to recover.
  4. Further, click Save and choose your preferred option for the saving location.
  5. Opt for Database/Script as needed, apply other filters, and at last, click OK.

With this, your log files are recovered, and the error is removed from them without any hassle. 

Conclusion

To conclude, understanding how to check and access SQL Server Error Log files is an essential skill. Every database administrator or developer must know about it to debug the critical errors and keep the SQL environment healthy. You can troubleshoot the SQL log services with any of the ways given above. Also, if your error log files are damaged or affected, recover them with a professional tool with ease. 

Frequently Asked Questions

Q.1 How to check error log in SQL Server using a query?

Ans. To check the MS SQL error log by executing a transaction query, run the following command:
EXEC dbfr.xp_readerrorlog;

Q.2 How do I create an error log in SQL Server?

Ans. To create a new error log in MS SQL Server, follow the given steps:
1. Run the command EXEC sp_cycle_errorlog to build the error log file.
2. Next, input the custom info into the SQL log.
3. Further, create a manual custom log table to track the log errors.
4. Now, automate the logging process with try/catch or INSERT commands.
5. Finally, view the new error logs through the SSMS.

About The Author:

Meet Shivam, an experienced SEO executive and content strategist. He combines creativity with strategy to craft engaging content that connects with audiences and supports brand goals. With strong expertise in digital marketing and content planning, Shivam helps businesses thrive online.

Related Post