How to enable logging for Dts.Log statements in a SSIS Script Task

If you want to log from a script task, you can use the Dts.Log function.

This function can log to the system table: dbo.sysssislog. If you configure you’re package logging correctly.

 

Notes

Most importantly, if you want to log from a script task by using the function Dts.Log, enable logging for the specific script task and enable "ScriptTaskLogEntry"

 

Steps to enable logging from within you SSIS script task
Make sure you’re Script Task contains a Dts.Log function call, like:

public void Main() { // Define log message string message = "This is my log text"; // Log the message Dts.Log(message, 999, null); Dts.TaskResult = (int)ScriptResults.Success; }

In the control flow right click and choose Logging…

Check all checkboxes in the treeview, make sure the script task is not grayed out or unchecked

Click on the top node in the treeview and add SSIS log provider for SQL Server:

 image

Enable ScriptTaskLogEntry in the details tab of the script task

image

When you run this package, you should see the logging in the table dbo.sysssislog

4 Comments

  1. Robert Catalano

    I ran into an instance where my script task was grayed out preventing me from enabling ScriptTaskLogEntry. To fix this right click your script task > properties and set “LoggingMode” to “enabled”. Mine defaulted to “UseParentSetting” which did not have an option to enable “ScriptTasakLogEntry”.

  2. Robert Catalano

    I ran into an instance where my script task was grayed out preventing me from enabling ScriptTaskLogEntry. To fix this right click your script task > properties and set “LoggingMode” to “enabled”. Mine defaulted to “UseParentSetting” which did not have an option to enable “ScriptTaskLogEntry”.

Leave a Reply

Your email address will not be published. Required fields are marked *