trace

  • To meet a security requirement, I created a custom trace to audit certain security events.

    Here's the create trace statement

    EXEC sp_trace_create @traceid = @tid OUTPUT ,

    @options = 6 , @tracefile = N'd:\customTrace\SQLServerSecurityEventAudit'

    I then add events to it and to get the trace started I run the stored proc EXEC sp_trace_setstatus @traceid = 1, @status =1

    The trace stops and seems to disappear totally (not even showing up as closed) if the box gets rebooted. Is there anyway to configure the trace to automatically start after a reboot?

  • You can put it in a proc and mark it as a start up proc. Sp_procoption maybe?

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • Andy has the best solution.

    Steve Jones

    steve@dkranch.net

  • Thanks! I made a stored procedure out of the trace create files and used sp_procoption to configure it to execute at startup.

    Do you know if the the .trc file the trace writes to will get overwritten or appended to each time there is a restart?

  • Also, in Windows Explorer the .trc file that the trace is writing to shows that the size is 0 until the trace is closed. It even shows size 0 when the trace is paused.

    Why is that and is there a way to determine the size of the file while the trace is running?

  • Never thought to check on the trc overwrite, I usually use datetime for the filenames. I think you have to close the file and reopen. Might look at how the rollover functionality works.

    Andy

    http://www.sqlservercentral.com/columnists/awarren/

  • The trace is set for trace file rollover.

    After a restart or a manual closing of the trace, if the file name in the stored procedure is already existing then the trace will not start. If I enter a different filename in the stored procedure then the trace gets created

    Hope this doesn't sound dumb but how do you use datetime for filenames? Do you use a function to get the time and use it as the filename?

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

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