Since I started blogging on SQL Server on Linux, I was asked a couple of questions on it. One of the most common questions was on SQL Server Error log. Therefore, I decided to write this blog. It may help you to explore all possible way to read the SQL Server Error Log file on a Linux System.
Before I demonstrate, I would like to emphasis – “It is really just SQL Server”; it does not matter whether it is running on Linux or Windows. The functionality of SQL Server remains same. Hat off to SQL Server product team who made it happen.
Let’s explore the methods to read SQL Server Error Log on a Linux system.
Method-1
- Go to the default location of SQL Server Error Log file on a Linux machine
Syntax: cd /var/opt/mssql/log
Syntax: ls -l
- Read the error log file using Linux command “cat”
Syntax: cat <errorfilename>
Method-2
- Connect to SQL Server on Linux Instance using SQL Server Management Studio and read the error log file
Syntax: xp_readerrorlog
Method-3
a) Connect and read the error log data in one shot from SQL Server on Linux Instance using SQLCMD tool
Syntax: sqlcmd -S localhost -U <username> -P’password’ -Q “xp_readerrorlog”
b) First connect to SQL Server on Linux Instance using SQLCMD tool and then read the error log file
Syntax: sqlcmd -S localhost -U <username> -P’password’
Summary:
The above demonstrations confirm that the functionality of SQL Server remains same on the Linux system. When you read the SQL Server error log file from SQLCMD tool, you may face some difficulties because of text formatting issue.
4 thoughts on “Read SQL Server Error Log on Linux System”
Hi
Hi Maruti, Let’s me know, if you have any question…
Thank you for all your valuable posts regarding “SQL server on Linux”. These all are very useful Dharmendra.
Thank you so much for your valuable input Pavithra!