I want to know where to see SQL Server start/stop logs for each instances and SQL Server agent/job start/stop logs? I am developing some tools to monitor SQL Server status. I am using SQL Server 2008 Enterprise.
thanks in advance, George
1. Find out who log in your PC and then verify with him whether he or she has stoped the SQL Service. If the answer is helpful, please click "Accept Answer" and upvote it.
Method 2: Find Last Start Time for SQL Server using SQL Server Error Log. If you open the current SQL Server error log in SSMS under Management > SQL Server Logs and scroll to the bottom of the error log you can see when the server was started.
By default, the SQL Server error log is stored in the Program Files\Microsoft SQL Server\MSSQL\Log directory. The most current error log file is called ERRORLOG. If you stop and re-start SQL Server, the old log will be archived and a new one will be created. In addition, you can re-cycle the error log by executing the DBCC ERRORLOG command or the sp_cycle_errorlog system procedure.
http://sqlserverpedia.com/wiki/SQL_Server_Error_Logs
There are some undocumented but well know system procedures to read the errorlog from SQL itself:
exec xp_enumerrorlogs 1
will list SQL Engine errorlog file numbersexec xp_readerrorlog <errorlognumber>, 1
will return the content of the requested Engine errorlog file.exec xp_enumerrorlogs 2
will list the Agent error log file numbersexec xp_readerrorlog <errorlognumber>, 2
will return the content of the requested Agent error log file. These are the procedures invoked by Management Studio to show the Engine and Agent logs.
If you are using .NET you can also use the Microsoft.SqlServer namespace to get most of this data programatically. For example, I have used Microsoft.SqlServer.Rmo to get the status of subscribers to a merge replication publication. Depending on what you are using it for, you may be able to avoid accessing (and presumably parsing?) the logs directly.
Check out the Microsoft.SqlServer.Management.Smo.Agent namespace for data specific to the SQL agent.
By using the Microsoft.SqlServer.Management.Smo.Agent namespace, you can do the following:
- View and modify SQL Server Agent settings.
- Set up and manage operators.
- Set up and manage alerts based on system messages or performance conditions.
- Set up and manage jobs with multiple steps and schedules.
- Manage proxy accounts for the subsystems on which jobs run.
- Manage jobs that run on multiple servers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With