SQL Server Logs Export

  • Does anyone have a script that I could use to export my SQL Server Log to a text file?

    Your help is greatly appreciated.

  • They already are text files.

    On my local machine, this is the path: C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Log

    Each of them are stored as ERRORLOG, ERRORLOG.1, ERRORLOG.2 and so forth.  They can be opened with any text editor.

     

     

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • I believe that SQL Server logs are already text files.  On your server, take a look at the following or equivalent folder:

    C:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Log

    The files named:  ERRORLOG.*  are the SQL Server error logs in text format.

    The files named:  SQLAGENT.*  are the SQL Server Agent logs in text format.

    If you don't have direct access to the drive it is installed on, then you could use xp_readerrorlog to get a listing:

    https://www.sqlserver-dba.com/2016/03/how-to-use-xp_readerrorlog-parameters-to-search-sql-error-logs.html

     

  • I believe the SQL Server Log and SQL Server Error log are different; the SQL Server Log is what I need help with exporting.  Is this log found in the same directory as the error log?

  • EMtwo wrote:

    I believe the SQL Server Log and SQL Server Error log are different; the SQL Server Log is what I need help with exporting.  Is this log found in the same directory as the error log?

    No, they are not.

    If you are looking at "SQL Server Logs" in SSMS, that is contained in the ERRORLOG, ERRORLOG.1, and so forth.

    If you are looking at "Error Logs" under SQL Agent in SSMS, that is contained in the SQLAGENT.* files.

    As Chris said, you can use xp_readerrorlog to get to the data in these files via query.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • Got it! Thanks so much.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply