meta données pour cette page
  •  

Ceci est une ancienne révision du document !


Error Log

localisation Logs

SELECT SERVERPROPERTY('ErrorLogFileName')
 
(No column name)
C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Log\ERRORLOG

Accéder aux logs

Exec xp_ReadErrorLog <LogNumber>, <LogType>, <SearchItem1>, <StartDate>, <EndDate>, <SortOrder>

  • LogNumber: It is the log number of the error log. You can see the lognumber in the above screenshot. Zero is always referred to as the current log file
  • LogType: We can use this command to read both SQL Server error logs and agent logs
    • 1 – To read the SQL Server error log
    • 2- To read SQL Agent logs
  • SearchItem1: In this parameter, we specify the search keyword
  • SearchItem2: We can use additional search items. Both conditions ( SearchItem1 and SearchItem2) should be satisfied with the results
  • StartDate and EndDate: We can filter the error log between StartDate and EndDate
  • SortOrder: We can specify ASC (Ascending) or DSC (descending) for sorting purposes
EXEC xp_readerrorlog 
    1, 
    1, 
    N'log', 
    NULL, 
    N'2025-11-22 09:00:00.000', 
    N'2025-11-22 10:00:00.000',
	N'desc'