Bandwidth Monitor
How can I overwrite the package log for each execution
By Darren Green
Version 7.0/2000
Level Beginner

The package error log file can be very useful in diagnosing problems that occur during package execution, and is particularly useful when working with scheduled packages.

For each execution information is appended to the end of the file. Over time this file can grow quite large, especially if the package runs on a frequent schedule. There is no overwrite option available within the DTS package object, but you simulate this yourself by using an ActiveX Script Task to delete the file during the package execution. The log is not written until all tasks have been completed, so the ActiveX Script Task does not even have to be the first task in the package, and you will not loose any information for the current execution by doing this. This behavior is not always desirable as it means you cannot check on the progress of a package during execution, but in this instance it is rather useful.

The following script reads the filename directly from the package object itself and uses the scripting FileSystemObject to perform the delete operation.

' Pkg 240 (Overwrite Pkg Log)
Option Explicit

Function Main()
	Dim oFSO, sLogFile

	sLogFile = DTSGlobalVariables.Parent.LogFileName 

	Set oFSO = CreateObject("Scripting.FileSystemObject")

	If oFSO.FileExists(sLogFile) Then
		oFSO.DeleteFile sLogFile, True
	End If

	Set oFSO = Nothing

	Main = DTSTaskExecResult_Success
End Function