December 9, 2012 at 1:18 pm
Hi,
I am planning to run a server side trace on server. I am bit worried about the trace file growing and consuming all the C drive. I like to set a maximum size for this trace file and like old events to drop off in a FIFO manner. Can this be done? Please advise how to achieve this ?
December 9, 2012 at 3:22 pm
Do you have any reason why you want to run these traces all the time? What do you want to achieve ? What's your task?
***The first step is always the hardest *******
December 10, 2012 at 2:54 am
Basically, for performance troubleshooting reasons we need to capture certain TSQL command from the Dynamics NAV2013 application, which sends the end user information as comments to the SQL server.
So I am planning to run a server side trace to capture this, applying the necessary filter. I am also planning to read this trace into a SQL table regularly. I considered using extended events but the events I am after is only fully supported in SQL2013. So this server side trace solution is only for SQL2008.
December 10, 2012 at 3:03 am
rama.mathanmohan (12/10/2012)
Basically, for performance troubleshooting reasons we need to capture certain TSQL command from the Dynamics NAV2013 application, which sends the end user information as comments to the SQL server.
always try to put some filters to minimize the logging plus space usage. in your care you can set a textdata filter for that TSQL command , it will give you all required information related with that
-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
December 10, 2012 at 3:54 am
Hi Bhuvnesh,
Thanks for your response. I am after a way in which you configure the server side trace so that it drops the old entries in a FIFO (first in first out) basis. Do you know how to do it ? Any script will be very handy.
December 10, 2012 at 4:00 am
When you choose "save to file" in profiler you have options "Enable file rollover" and "Set maximum file size", set them for your needs, set any additional parameters, choose only these events in which you interested in, set proper filters. Run and immediately stop trace choose "File->Export->Script Trace Definition" and you have script to set server trace with rollover file.
December 10, 2012 at 4:45 am
Is the rollover option will limit the size of the files used in total with out stopping the trace from collecting data ? Please note, Since this is an "unmanned process" I am trying to ensure it will not consume the C drive eventually. Can you please confirm this.
December 10, 2012 at 6:15 am
I forgot, you must then add @filecount options to sp_trace_create in script generated by Profiler,
explanation and examples here: http://www.sqlservercentral.com/articles/SQL+Trace/71841/
December 10, 2012 at 6:18 am
rama.mathanmohan (12/10/2012)
Is the rollover option will limit the size of the files used in total with out stopping the trace from collecting data ? Please note, Since this is an "unmanned process" I am trying to ensure it will not consume the C drive eventually. Can you please confirm this.
yes, when the option TRACE_FILE_ROLLOVER is true, it limits the size of data captured,and will not stop the trace.
A specific example:
if you set the rollover option & number of files, then the oldest data will be pushed off in favor of the new data;
this exampel would keep 500 meg of data.
declare @path nvarchar(256)
declare @traceidout int
declare @maxfilesize bigint
declare @maxRolloverFiles int
declare @on bit
set @on = 1
set @maxRolloverFiles = 10 --10 files in total
set @maxfilesize = 50 --meg so we are keeping the "latest" 500 meg of changes(10 x 50M)
--we want the current trace folder
--ie c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG
SELECT @path = REVERSE(SUBSTRING(REVERSE(path),CHARINDEX('\',REVERSE(path)),256)) FROM sys.traces WHERE is_default = 1
SET @path = @path + N'MyDMLtrace2' --system appends .trc automatically for the filename
exec sp_trace_create @traceid = @traceidout output,
@options = 2, -- TRACE_FILE_ROLLOVER = TRUE, SHUTDOWN_ON_ERROR = FALSE
@tracefile = @path,
@maxfilesize = @maxfilesize,
@stoptime = NULL,
@filecount = @maxRolloverFiles
Lowell
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply