Tải bản đầy đủ - 0 (trang)
15-2. Logging Data from SSIS

15-2. Logging Data from SSIS

Tải bản đầy đủ - 0trang

Chapter 15 ■ Logging and Auditing

Figure 15-1.  Selecting log destinations


Click the Details tab of the dialog box, and then the task for which you want to select

logged events.


Check the Events checkbox to select all events.


Click OK.

When you run your SSIS package, all the events that you selected will be logged to the providers that you


How It Works

SSIS comes with advanced and complete logging facilities that allow you to track the progress and status of an

SSIS package as it executes. Indeed, you have seen SSIS logging if you have viewed the Progressor Execution

Resultstab in BIDS/SSDT—for you are seeing much of the same log information here as you will see in your

custom logging.

Using this built-in logging infrastructure requires you to answer three basic questions:

How are you going to log events?

Which steps in the SSIS package do you want to log?

What events do you want to log for each package step?



Chapter 15 ■ Logging and Auditing

The “how” part means where you want to store logged information—or which log provider you wish to use,

in SSIS terms. These include the following:

An SQL Server table

An XML file

A text file

An SQL Server Profiler Trace file

The Windows event log

Any combination or all of these can be used concurrently. Each, of course, must be read using an

appropriate tool. Indeed, most can be converted to another type of log using tools such as LogParser—described

in Recipe 2-21. SSIS logging is, in essence, a simple set of options to be enabled.

■■Note  While describing how to log events from SSIS, I want to add a quick comment. This approach, while not

exactly deprecated in SQL Server 2012, has been largely superseded by the SSIS catalog in the SSIS server. You can

still use this approach in SQL Server 2012 (and have no other real alternative in previous versions), but you need to

be aware that there is now another solution available. This new technique is explained in Recipes 15-16 to 15-18.

Once you know where you want to save logging information, you can decide what information to save and

for which package step. This information is the Logged Event in SSIS-speak, and is described in Table 15-6.

Table 15-6.  Logged Events in SSIS




The reasons and resulting sizes of changes in buffer sizes (In the Data Flow

task only).


Returns package diagnostics information.


Displays Error events.


Displays changes in task execution status.


The file system operation that was performed (In the File System task only).


Displays Information events. These are task-specific and vary according to

the task selected for logging.


Outstanding (memory-hogging) buffers consuming memory (In the Data

Flow task only).


Information on the validation and execution of each Data Flow component

(In the Data Flow task only).


The execution plan for a data flow (In the Data Flow task only).


The scheduler input when the execution plan is being created (Data Flow

task only).


Information from Pipeline Initialization (In the Data Flow task only).




Chapter 15 ■ Logging and Auditing

Table 15-6.  (continued)




A component is given an end-of-rowset signal.


A component has returned from its Prime Output call.


A component is given a pre-end-of-rowset signal.


A component is given its pre-Prime Output call.


Rows were provided as input to a dataflow component.


Displays events occurring during the post-execute phase.PostExecute



Displays events occurring during the post-validation phase.PostValidate



Displays pre-execution events occurring during the pre-execute phase.


Displays events occurring during the pre-validation phase.


Handles progress notifications.


Handles Cancel events. Polled at intervals to determine whether to cancel

package execution.


Handles task failures. Indicates that a task has failed.


Displays Warning events. These vary according to the task selected for

logging. They are task-specific.

Once again, any or all of these events can be logged to all selected log providers.

A word of warning: it is easy to go overboard when logging SSIS packages, and to consequently end up with

massive files (or tables) of log data, where it is impossible to see the woods for the trees. So be cautious when

selecting the events you wish to log, given that judicious selection is as important as logging itself. Equally,

logging events to all the log providers is usually complete overkill and normally one log provider will suffice.

Hints, Tips, and Traps

To add, remove, or reconfigure a logging provider, click Logging in the left-hand pane

first. Otherwise, however hard and often you click a log to use, you will not be able to

select it.

Log provider configuration uses standard SSIS connection managers. These can be edited

directly from the Connection Managers pane.

Configuring the log provider for SQL Server logging will create the sysssislog table in

the destination database (this will be sysdtslog90 for SQL Server 2005). SSIS will also

create the sp_ssis_addlogentry (sp_dts_addlogentry stored procedure in SQL Server

2005) in the destination database, which is used by SSIS to write log information to the

destination table. Both can be tweaked if you prefer, as described in Recipe 15-4.



Chapter 15 ■ Logging and Auditing

Only experience will teach you which pieces of logging information you really need

in each different set of circumstances. Generally, it pays to begin testing with as much

logging information as you can digest, and then to reduce the number of events logged as

you move into production. The sheer quantity of information made available can result in

a counter productive flood of data that is never used, unless a modicum of moderation is

applied in practice.

15-3. Customizing SSIS Logging


You need to select the SSIS events to log with greater precision and subtlety than the Recipe 15-2 solution



Choose the events to log and the details to be logged for each event.


Follow steps 1 through 5 of Recipe 15-2 to configure SSIS logging.


In the Configure SSIS Logging dialog box, click the Details tab, and then click the

Advanced button.


Select (or deselect) the event details you wish to log for each logged event. You should

end up with something like Figure 15-2.

Figure 15-2.  Selecting events to log


Click OK to confirm and close the dialog box.



Chapter 15 ■ Logging and auditing

How It Works

As simple as SSIS logging is, there are nonetheless a few available tweaks to allow developers to

Select logged details.

Load and save logging details.

Reapply logging details.

Modify the logging details file.

Choosing an event to trigger logging is only part of the story. All events can log the

Computer (the name of the computer).

Operator (the user executing the package).

Source (the package).

Sourceid (the package identifier).

ExecutionID (the GUID of the execution context—the parent or child package).

MessageText (any message returned).

Databytes (currently unused).

As well as the

Event (the name of the event).

StartTime (the exact date and time the event began).

EndTime (the exact date and time the event ended).

15-4. Saving and Applying Complex SSIS Logging Details


Redefining the same set of logging details for SSIS tasks is too time-consuming.


Save the set of log details to an XML file, and then re-apply them.


In the left pane, select the task whose logging details you wish to save.


In the Configure SSIS Loggingdialog box, click the Details tab, and then click the Save



Choose a path and enter a file name.

(C:\SQL2012DIRecipes\CH15\MyTaskLogDetails.Xml in this example).


Click Save.


Click OK.



Chapter 15 ■ Logging and Auditing

Then SSIS lets you save the details of task logging, and then re-apply them to multiple packages quickly and

easily, like this:


Select the task whose logging details you wish to modify.


In the Configure SSIS Logging dialog box, click the Details tab, and then click the

Load button.


Select the previously saved logging details file



Click Open.


Click OK.

How It Works

If you have defined a complex set of logged details for a task (a Data Flow task, for instance), it can be extremely

laborious and time-consuming to redefine the same logged events, individually, for multiple similar tasks. If you

have saved a set of details to log, they can be applied to another SSIS package.

As logging details are saved as XML, you can edit the resulting XML in any text editor or any XML editor

(such as XML Notepad from Microsoft). You will need to reapply any saved packages to existing tasks should you

wish for these changes to be applied to your tasks. An abbreviated example of a saved file follows:

xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="TaskHost"










As you can see, the structure is mercifully simple, and so it is easy to edit the XML file to add or remove

EventsFilters and Filters.

Hints, Tips, and Traps

You cannot load logging details for multiple tasks simultaneously.

To apply all the logging details for a type of task, you are better loading the logging details

file saved from a similar type of task. For instance, a File System task contains logging

details for FileSystemOperation. So to apply your selections for this type of logging

detail, you must first save logging details from a File System task.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

15-2. Logging Data from SSIS

Tải bản đầy đủ ngay(0 tr)