Reading the SQL Server error logs.
sp_readerrorlog
sp_readerrorlog is a stored procedure in the master database. It checks that the user is part of the securityadmin, then calls xp_readerrorlog. Header of the log gives server information and location of the log files.
| Order | Type | Description |
|---|---|---|
| 1 | int | number of the log file. default is 0 for current file |
| 2 | int | LogType, default 1. 1 = SQLServer logs, 2 = SQLAgent logs, 3 = full text logs |
| 3 | varchar(255) | default NULL — search string for the log entry |
| 4 | varchar(255) | default NULL — search string for the log entry |
| 5 | datetime | from date-time |
| 6 | datetime | to date-time |
| 7 | varchar | Order, default to “ASC”. “ASC” or “DESC” |
Start a new error log
sp_cycle_errorlog
By default the number of logs is 7.