Вопрос

What I want to know, is how to follow the evolution of log file size in time? Does SSMS provide a tool to do so?

The option of writing a script that checks from time to time the size of the file is indeed doable, but before getting in, can anyone please tell if such a tool exists already in SSMS?

Thank you,

Это было полезно?

Решение

I use the following script (powershell) when I need to do this:

$doforever = 1

$cn2 = new-object system.data.SqlClient.SQLConnection("Data Source=somedatasource;Integrated Security=false;Initial Catalog=master;User  ID=sa;Password=somepasswordimnottelling");
$cmd = new-object system.data.sqlclient.sqlcommand("dbcc sqlperf(logspace)", $cn2);
$cn2.Open();

do 
{
$ds=New-Object system.Data.DataSet
$da=New-Object system.Data.SqlClient.SqlDataAdapter($cmd)
[void]$da.fill($ds)

$ds.tables[0] | out-string | %{$_.split("`n")}| %{$_ -replace("\s+",",")}|%{"{0},{1}" -f (get-date -format 'dd/MM/yyyy HH:mm:ss'),$_} | add-content -path c:\perflogs\admin\logsize.csv

sleep -s 300
}
while ($doForever -eq 1)

Quick and dirty - I know it can be refined :)

Другие советы

It won't give you exact values of log file size in time, but you can use trace to filter 'grow log file' events. This should also appear in default trace (enabled by default :)). I know this applies to SQL Server 2005 and 2008, not sure about other editions (and I don't know which one do you use). You'd use ::fn_trace_gettable function for this. As a parameter you specify default trace files location (it automatically parses all the files in a directory, you just need to give "log.trc" as filename.

There is a tool available in SQL Server 2008 and later called Data Collector. If you have enabled Data Collection on your server you can track historical Data and Log file changes as well as observe auto-growth events for specific databases.

MSDN Data Collector

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top