meta données pour cette page
  •  

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
sql_server:database:mssql-errorlog [24/11/2025 08:19] – créée mdlsql_server:database:mssql-errorlog [24/11/2025 08:25] (Version actuelle) mdl
Ligne 2: Ligne 2:
  
  
-  * localisation Logs+__localisation Logs__ 
 + 
 <code TSQL> <code TSQL>
 SELECT SERVERPROPERTY('ErrorLogFileName') SELECT SERVERPROPERTY('ErrorLogFileName')
Ligne 8: Ligne 10:
 (No column name) (No column name)
 C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Log\ERRORLOG C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Log\ERRORLOG
 +</code>
 +
 +
 +__lister les numéros de logs__
 +<code TSQL>
 +EXEC sys.sp_enumerrorlogs;
 +
 +Archive # Date Log File Size (Byte)
 +0 11/24/2025  08:58 64986460
 +1 11/22/2025  23:57 7926818
 +2 11/22/2025  10:55 292378122
 +3 11/15/2025  23:57 808864
 +4 11/15/2025  23:03 484982
 +5 11/15/2025  23:01 5847440
 +6 11/15/2025  10:58 430784880
 +</code>
 +
 +
 +__Accéder aux logs__
 +
 +//Exec xp_ReadErrorLog  
 + &lt;LogNumber&gt;, 
 + &lt;LogType&gt;, 
 + &lt;SearchItem1&gt;, 
 + &lt;StartDate&gt;, 
 + &lt;EndDate&gt;, 
 + &lt;SortOrder&gt;//
 +
 +    * **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
 +
 +<code TSQL>
 +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'
 </code> </code>