SQL Server Health Check

[4 ways] How To Check SQL Server Error Log Location?

Updated June 25, 20265 min read

If you can connect to the SQL Server instance, run this read-only query to find its Database Engine error-log path:

SELECT SERVERPROPERTY('ErrorLogFileName') AS ErrorLogFileName;

On Windows, if the instance will not start, open SQL Server Configuration Manager, select the instance's properties, and read the path after -e on the Startup Parameters tab. You do not need to change a setting or restart the service to find the path.

This is the Database Engine ERRORLOG, not the database's .ldf transaction log or SQL Server Agent's log. A custom installation can use a different path, so use the instance's actual setting rather than assuming the default folder.

4 step by step methods to find SQL Server error log location

You can check the SQL Server error log path in a few ways:

  1. Use T-SQL
  2. Use SQL Configuration Manager
  3. Use Event Viewer
  4. Registry

1. Using T-SQL

Find the SQL Server error log location setting:

USE master
GO

EXEC sys.xp_readerrorlog 0
	,--Value of error log file you want to read: 0 = current, 1 = Archive #1, 2 = Archive #2, etc...
	1
	,--Log file type: 1 or NULL = error log, 2 = SQL Agent log
	N'Logging SQL Server messages in file'
	,--Search string 1: String you want to find
	NULL
	,--Search string 2: String two you want to search for to further refine the results
	NULL
	,--Search from start time
	NULL
	,--Search to end time
	N'asc' --Sort order for results: N'asc' = ascending, N'desc' = descending

The result should be:

Figure 1 - Get SQL error log location using T-SQL
Figure 1 - Get SQL error log location using T-SQL

2. SQL Configuration Manager

Accessing SQL Server Configuration Manager:

  1. Go to SQL Server Services
  2. Click on the SQL instance on the right (In my case it's “SQL2017”)
  3. Right-click, go to Properties
  4. Look for the Startup Parameters tab

One of the “Existing parameters” shows the error log path.

SQL Server error log default location in Configuration Manager
Figure 2 - SQL Server error log default location config

Here is the location of SQL Server logs on my laptop:

On Linux, the default error-log file is /var/opt/mssql/log/errorlog. On Windows, the active file is normally named ERRORLOG; numbered files such as ERRORLOG.1 are archived logs. Custom paths can differ.

Figure 3 - SQL Server error log location SQL Server 2017 (PATH)
Figure 3 - SQL Server error log location SQL Server 2017 (PATH)

3. Using Event Viewer

Start the Event Viewer (you can use the search box near the Start button).

  1. Click on the Windows Logs > Application > Filter Current Log
  2. Replace <All Event IDs> with EventID 17111 and hit OK.
Figure 4 - Microsoft Windows Event viewer error log file path (Location)
Figure 4 - Microsoft Windows Event Viewer error log file path (location)
Figure 5 - Adding filter to current log (Event Viewer)
Figure 5 - Adding a filter to the current log (Event Viewer)
Figure 6 - Steps to filter Event viewer log
Figure 6 - Steps to filter Event Viewer log

4. Using registry

Are you serious? Are you going to try to look up the path using the registry?

Yeah, it is possible.

You have three methods above to do this. I do not see a good reason to go the registry route, but in case you must, here it is:

Figure 7 - Finding the SQL Server error log using registry
Figure 7 - Finding the SQL Server error log using the registry

The steps above only locate the log. The optional instructions below change where logs are written. Plan a maintenance window before restarting SQL Server, and first verify that the destination folder exists and that the SQL Server service account can write to it. A bad path or missing permission can prevent the instance from starting.

To change or move the error log path, I do this using SQL Server Configuration Manager. Change parameter -e.

Restart the SQL Service.

You will most likely get the “The request failed or the service did not respond in a timely fashion...” error.

To check the SQL Server Agent error log location, go to SQL Server Management Studio > SQL Server Agent > right-click on Properties.

Figure 8 - SQL Server Agent error log check path
Figure 8 - SQL Server Agent error log check path

To change the SQL Server Agent error log, just run this:

USE msdb;
GO

EXEC msdb.dbo.sp_set_sqlagent_properties
    @errorlog_file = N'<New_Errorlog_Path>\SQLAGENT.OUT';
GO

When reviewing the SQL Server, checking the error log is one of the first things I do.

It often has a lot of good info!

Discover More

Discover what clients are saying about Red9

Red9 has incredible expertise both in SQL migration and performance tuning.

The biggest benefit has been performance gains and tuning associated with migrating to AWS and a newer version of SQL Server with Always On clustering. Red9 was integral to this process. The deep knowledge of MSSQL and combined experience of Red9 have been a huge asset during a difficult migration. Red9 found inefficient indexes and performance bottlenecks that improved latency by over 400%.

Rich StaatsRich StaatsCloud EngineerMetalToad
See more testimonials

Check Red9's SQL Server Services

SQL Server Consulting

Perfect for one-time projects like SQL migrations or upgrades, and short-term fixes such as performance issues or SQL remediation.

Discover More ➜

SQL Server Managed Services

Continuous SQL support, proactive monitoring, and expert DBA help with one predictable monthly fee.

Discover More ➜

Emergency SQL Support

Take the stress out of emergencies with immediate access to a SQL Server Sr. DBA 24x7x365

Discover More ➜

Explore All Services ➜