Most businesses want to keep track of the packages running on their servers. The logging options in SSIS enable you to record package information at run time. This lesson shows you how to use those built-in logging options. There is a whole new logging ability built into the SSIS catalog covered in Lesson 52.
To set up logging with the built-in SSIS logging option, right-click in the Control Flow of a package and select Logging. This action opens the Configure SSIS Logs window, as shown in Figure 47-1. To log information from the package you need to place a check next to the package name in the left pane.
The drop-down menu of provider types has the available logging locations where you can save the information from the package. The options are as follows:
Regardless of the provider type you select, options are available as to what data you want to log and when this data is logged. You can see these options under the Details tab of the Configure SSIS Logs window, as shown in Figure 47-2.
Under the Details tab, you select the event you want to be logged. If the event occurs during the run of the package, it logs data to the selected provider. The most commonly used events are onError, onWarning, onPreExecute, and onPostExecute.
If you select onError, if an error occurs during the execution of the package, data is stored in the selected log provider. If an error never occurs during the package execution, then no data is logged for this event. The same holds true with onWarning for warnings occurring during the package execution.
The onPreExecute event logs all the data before the package begins execution. This gives you a chance to see what the data values were before the packages performed any tasks. The onPostExecute event option logs all of the data after the package has completed execution.
The data that is saved by the SSIS logging options is shown in the Advanced window, as shown in Figure 47-3, which you bring up in the Details tab by clicking the Advanced button at the bottom of the screen. In the Advanced screen, you can select what data you want to log and on what event. You can select or unselect each item on each event. So if you want to log the computer name, but only on the onPreExecute, you can place a check under the Computer column next to the onPreExecute event only and make sure it is unchecked for the other events. This is the limit of the customization allowed by the built-in SSIS logging.
To create a log provider, select a provider type from the Provider Type drop-down menu on the Providers and Logs tab in the Configure SSIS Logs window, and then click the Add button. The log provider then appears in the Select the logs to use for the container pane below the drop-down menu. Place a check under the Name column to turn on the log provider. If you want to disable a log, but not remove it from this log menu, you need only remove the check in the Name column next to that log provider.
After you have created the log provider and checked the Name column to activate it, click the Configuration drop-down menu. If a connection type exists in the connection manager that is used by the selected provider, it shows in this window. If the connection does not exist, you can create it by clicking the <New connection…> option.
Next, click the Details tab to choose the events you want to log. If you want to log all events, click the check box next to the Events title at the top of the events list to select all. If you want to select just individual events, place a check next to the event you want to be logged.
After you have selected the events, click the Advanced button and uncheck any data you do not want to log so you don’t have that data saved. You can also save the configuration you have selected to an XML file with the Save button that appears at the bottom of the Details tab. Later you can use this XML file in another package to select the same check boxes in this logging configuration screen automatically by clicking the Load button that also appears at the bottom of the Details tab.
In this Try It, you create a package with a Script Task that causes an error and logs the package information on the error, before it runs and after it completes. After this lesson, you will have an understanding of how to use SSIS logging to audit the running of your packages.
You can download the completed Lesson47.dtsx from www.wrox.com.
Create a package with a Script Task. Edit the Script Task to open a message box pop-up with a variable that does not exist. Log the package onError, onPreExecute, and onPostExecute events.
msgbox(DTS.Variables(“Test”).Value)