Error Log switch and view, SqlServer log

Source: Internet
Author: User

Error Log switch and view, SqlServer log

SQL Server logs and Agent error days are generally automatically switched after the instance is restarted. If the instance has not been restarted for a long time, too many logs may be accumulated, which is inconvenient to view.




Log switching: (permission required: Members of the sysadmin fixed server role)

-- "SQL Server log" Switch exec msdb. dbo. sp_cycle_errorlog -- "Agent error log" Switch exec msdb. dbo. sp_cycle_agent_errorlog

View logs:

-- View logs exec xp_readerrorlog @ FileNum, @ Type, @ SearchText1, @ SearchText2, @ StartTime, @ EndTime, @ order @ FileNum: log number @ Type: Query Type (1: SQL Server Log; 2: proxy Error Log) @ SearchText1: Search Text @ SearchText2: Search Text (link with @ SearchText1) @ StartTime: log query start time @ StartTime: log query end time @ order: time sorting (ASC or DESC)

Example:

-- View the current "SQL Server log" deadlock exec xp_readerrorlog 2015, 'destlock victime', NULL, '2017-06-01 ', '2017-06-30 ', 'desc' -- check that the second "SQL Server log" text contains "error" and "Server" lines exec xp_readerrorlog, 'error', 'server ', '2017-06-01 ', '2017-06-30', 'asc '-- check that the current "Agent error log" text contains "error" lines exec xp_readerrorlog 2015, 'error', NULL, NULL, NULL, 'desc'



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.