
Simple SSIS Logging
Simple logging to a text file for SQL Server Integration Services.
1 min read
Very simple logging to a text file can be configured for SSIS packages quite easily, as described below.
This method is mainly recommended for debugging during development. In production, logging to a database makes more sense, especially if the logs are to be processed automatically.
- First, create a variable “pLogPath” (string) with the value “.”. It is best set at runtime when the package is called.
- In the menu under SSIS > Logging…, add a new provider of type “Text File”.
- Create a new connection for the provider and configure a file path (arbitrary at this point).
- In the logging details, select the events “OnError”, “OnWarning”, optionally “OnPreExecute” and “OnPostExecute”, and others as needed.
- Confirm the logging dialog with OK and adjust the file name of the logging connection if necessary. (See below.)
Bonus: dynamic log file names
To create the log files with a dynamic file name (e.g. “PackageName_YYYYMMDD.log”), the following expression must be configured for “ConnectionString” in the log file connection manager:
@[User::pLogPath] + "\\" + @[System::PackageName] + "_"
+ (DT_STR,4,1252) DatePart("yyyy",@[System::StartTime] )
+ Right("0" + (DT_STR,4,1252) DatePart("m",@[System::StartTime]),2)
+ Right("0" + (DT_STR,4,1252) DatePart("d",@[System::StartTime]),2)
+ ".log"