Friday, 6 May 2016

Changing location of SQL Server error log file


Changing Sql server error log is a rare task ,but recently we had a request to move sql agent and server log to a  different  drive,so i will share the steps to change  the Sql Server and Sql server agents location log here

Changing SQL Server  error log path


Error log location is a startup parameter, so for changing sql server  error log we need to modify the  startup parameter '-e' in sql server configuration  manager for the instance you want to change error  log path.In the below snip you can see that my error log location is 'D:\ms sql\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log\ERRORLOG' and i am going to update it to 'F:\MSSQL\ERRORLOG' by changing the startup parameter '-e', since it is a startup parameter we need to restart the sql server to reflect the change made


once restarted you can see error log file created in the location we have mentioned , in my case i can see a file called 'ERRORLOG' created in the location F:\MSSQL


Changing Sql Server agent error log path

We have both Tsql option and GUI to change the error log location for sql server agent

1)Using GUI
     
    We can change Sql server agent error log location by changing the error log file name in sql server agent properties

2)Using TSQL

    Sql server agent log location can be changed by executing the below code

     USE [msdb]
     GO
     EXEC msdb.dbo.sp_set_sqlagent_properties @errorlog_file=N'mention log file path here'
     GO

For the change to be reflected we need to restart the sql server agent
we can verify the location by checking agent properties executing the below query

EXEC msdb.dbo.sp_get_sqlagent_properties 

No comments:

Post a Comment