介绍

本文中,我们将结合之前学习的时间冒泡,日志记录,以及复制模型.建立一个自定义的SSIS包日志模型.

SSIS Task事件回顾    Reviewing SSIS Task Events

在做实验之前我们更改一下 Precedence.dtsx SSIS 包的设置. 把 Precedence.dtsx SSIS 包的 DisableEventHandlers 属性改为True

Figure 2

屏蔽内置日志   Disable Built-In Logging

首先我们要移除已经存在的日志配置.点击SSIS 下拉菜单然后点击 Logging :


Figure 7

Configure SSIS Logs 显示以后点击Delete 按钮删掉之前的文本日志配置 .


Figure 8

从技术上来说,刚才的步骤做了以后.日志就不会记录了. 不过我有洁癖,所以把Containers这边的复选框也取消选择了

Figure 9

同样的可以把 file connection manager 也删掉


Figure 10

我们把Level 11配置的东西都删掉. 执行一下包,没问题就继续下面操作.

事件冒泡回顾  Event Bubbling, a Review

这里省略不翻译了,有需要的朋友可以看之前的章节

[译]Stairway to Integration Services Level 10 - 高级事件活动

父子模型日志记录的准备  Preparing for Parent-Child SSIS Design Pattern Logging

首先我们需要一个数据库和表来记录日志. 先创建一个名为 “SSISStairwayConfig”数据库. 代码如下:

Use master
go /* SSISStairwayConfig database */
If Not Exists(Select name
From sys.databases
Where name = 'SSISStairwayConfig')
begin
print 'Creating SSISStairwayConfig database'
Create Database SSISStairwayConfig
print 'SSISStairwayConfig database created'
end
Else
print 'SSISStairwayConfig database already exists.'
print ''
go

Listing 1

接着创建 “lg” schema 和“SSISErrors” 表:

Use SSISStairwayConfig
go
/* log schema */
If Not Exists(Select name
From sys.schemas
Where name = 'lg')
begin
print 'Creating lg schema'
declare @sql varchar(100) = 'Create Schema lg'
exec(@sql)
print 'Lg schema created'
end
Else
print 'Lg schema already exists.'
print ''
/* lg.SSISErrors table */
If Not Exists(Select s.name + '.' + t.name
From sys.tables t
Join sys.schemas s
On s.schema_id = t.schema_id
Where s.name = 'lg'
And t.name = 'SSISErrors')
begin
print 'Creating lg.SSISErrors table'
Create Table lg.SSISErrors
(
ID int identity(1,1)
Constraint PK_SSISErrors Primary Key Clustered
,ErrorDateTime datetime Not Null
Constraint DF_logSSISErrors_ErrorDateTime
Default(GetDate())
,ErrorDescription varchar(max) Null
,ErrorCode int Null
,SourceName varchar(255) Null
)
print 'Lg.SSISErrors created'
end
Else
print 'Lg.SSISErrors table already exists.'
print ''

Listing 2

记录父子SSIS设计日志      Applying the Parent-Child SSIS Design Pattern to Logging

打开Parent.dtsx SSIS 包,然后定位到 OnError 事件处理:


Figure 18

脱一个 Execute SQL Task到 OnError 事件处理界面然后与 Script Task 连起来:

Figure 19

打开 Execute SQL Task Editor 然后把 ConnectionType 属性改为 ADO.NET :

Figure 20

点开 Connection 属性下拉框,点击 “<New connection…>” :

Figure 21

点了以后会生成一个新的 ADO.NET Connection Manager 在Connection Managers 标签下面可以看到 :

Figure 22

Configure ADO.NET Connection Manager 编辑框:

Figure 23

点击New按钮配置一个新的数据连接. 选择我们刚才创建好的数据库

Figure 26

点几 OK 按钮关闭 Connection Manager 编辑器,返回Configure ADO.NET Connection Manager 显示如下:

Figure 27

数据连接会记录在你的配置文件里面. 以后部署好SSIS包依旧可以使用.

Figure 28

在 SQLStatement 属性里面输入以下代码 :

Insert Into lg.SSISErrors
(ErrorCode
,ErrorDescription
,SourceName)
Values
(@ErrorCode
,@ErrorDescription
,@SourceName)

Listing 3

这个我们创建的插入语句包含了三个参数 : ErrorCode, ErrorDescription, and SourceName.  点击parameter mapping 也来映射变量,点击Add按钮,配置如下图:

Figure 30

System::ErrorCode SSIS 变量的类型为 Int32 (integer) 与插入语句中的 @ErrorCode 参数映射.

Direction 包含 Input, Output, 和 Return 值.  Data Type 字段包含 ADO.Net 的数据类型 . (这个根据我们之前设置 Connection Type的不同而不同)

用ADO.Net 而 OLEDB 连接类型是有原因的: 在SQL语句和ADO.Net里面我都可以使用参数名.  而用  OLEDB 的话我不得不在SQL语句里面打上问号 . 而引用参数的时候还得打上编号( 0是第一个问号,1是第二个问号…. ) 我觉得 ADO.Net 语法更清楚.

再把另外两个参数也映射一下.

Figure 32

执行 Parent.dtsx SSIS 包 :

Figure 33

验证一下数据库中是否记录了错误 日志

Use SSISStairwayConfig
go
Select *
From lg.SSISErrors

Listing 4

结果如下 :

Figure 34

原文链接:

http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/96657/

项目文件:

My_First_SSIS_Project_After_Step_12.rar

[译]Stairway to Integration Services Level 12 - 高级日志配置的更多相关文章

  1. [译]Stairway to Integration Services Level 10 - 高级事件活动

    介绍 在前一篇文章中我们介绍了故障容差相关的 MaximumErrorCount 和 ForceExecutionResult 属性.  同时我们学习了SSIS Control Flow task e ...

  2. [译]Stairway to Integration Services Level 16 – Flexible Source Locations (多文件导入)

    介绍 在本文中我们将利用SSIS参数,变量 以及 Foreach Loop Container 从多个源动态导入数据. 开始前我们先下载一些数据.WeatherData_Dec08_Apr09.zip ...

  3. [译]Stairway to Integration Services Level 11 - 日志配置

    介绍 在前一个章节我们讨论了事先行为,分享了如何操作默认的行为和时间冒泡,并且介绍了父子模型. 本文中,我们会配置SSIS日志. 进行简单及高级日志配置,存储,和检索的实验.并且生成自定义日志信息. ...

  4. [译]Stairway to Integration Services Level 9 - Control Flow Task Errors

    介绍 在本文中,我们会实验 MaximumErrorCount和ForceExecutioResult 故障容差属性,并且还要学习Control Flow task errors, event han ...

  5. [译]Stairway to Integration Services Level 8 - SSIS 工作流管理高级

    介绍 在前两个章节我们,建立了一个新的SSIS包,简单的使用了一下scripting还有优先约束,并且测试了MaxConcurrentExecutables 属性.  同时实验了  “On Succe ...

  6. [译]Stairway to Integration Services Level 18 – 部署和执行

    介绍 在本文中,我们要创建一个SSIS Catalog 实例,部署我们的项目,并且运行 weather data loader 包. SSIS 2012 部署模型   SSIS 2012 Deploy ...

  7. [译]Stairway to Integration Services Level 13 - SSIS 变量回顾

    介绍 在前一篇中我们组合了已经学过的事件冒泡 event bubbling, 日志记录 logging, 和父子模型 Parent-Child pattern 建立了自定义的SSIS包日志记录. 本文 ...

  8. [译]Stairway to Integration Services Level 6 - SSIS 工作流管理基础

    简介 在之前的章节中,我们学习了增量载入数据. 本文中.我们通过优先约束(Precedence Constraints)来管理SSIS的工作流. 添加一个SSIS包 图 1 将新建的Package1. ...

  9. [译]Stairway to Integration Services Level 5 - 增量删除数据

    在 dbo.Contact中添加一行记录 Use AdventureWorks go Insert Into dbo.Contact (FirstName, MiddleName, LastName, ...

随机推荐

  1. codeforces 149E . Martian Strings kmp

    题目链接 给一个字符串s, n个字符串str. 令tmp为s中不重叠的两个连续子串合起来的结果, 顺序不能改变.问tmp能形成n个字符串中的几个. 初始将一个数组dp赋值为-1. 对str做kmp, ...

  2. 【LeetCode题意分析&解答】42. Trapping Rain Water

    Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...

  3. web编程速度大比拼(nodejs go python)(非专业对比)

    C10K问题的解决,涌现出一大批新框架,或者新语言,那么问题来了:到底谁最快呢?非专业程序猿来个非专业对比. 比较程序:输出Hello World! 测试程序:siege –c 100 –r 100 ...

  4. SQL Server 中大小写区分的处理

    SQL Server 中大小写区分的处理. 默认情况下,SQL Server 里面是不区分大小写的: E:\>sqlcmd -S "localhost\SQLEXPRESS" ...

  5. DelphiXe5中的双向绑定(使用使用TBindScope和TBindExpression,并覆盖AfterConstruction函数)

    在Delphi下等这一功能很久了,虽然C#下早已实现了这一功能.但是在Dephi下尝试这项功能时还是有些许的激动.闲言少絮,直接上代码. unit BindingDemo; interface use ...

  6. 使用Fiddler解析WCF RIA Service传输的数据

    原文 http://www.cnblogs.com/wintersun/archive/2011/01/05/1926386.html 使用Fiddler 2 解析WCF RIA Service传输的 ...

  7. 多线程中Local Store Slot(本地存储槽)

    在Java中有一种ThreadLocal机制,为每一个使用该变量的线程都提供一个变量值的副本,是每一个线程都可以独立地改变自己的副本,而不会和其它线程的副本冲突.从线程的角度看,就好像每一个线程都完全 ...

  8. jdk、jre与jvm的区别与联系

    为了学习数据库,重装了系统,之前前一直在用eclipse,现在准备换成myeclipse,这之前当然需要重新设置环境变量,顺手写下有关jdk.jre与jvm的区别与联系以供交流参考. 首先来说一下JD ...

  9. 浅析JQuery中的html(),text(),val()区别

    1.HTML html():取得第一个匹配元素的html内容.这个函数不能用于XML文档.但可以用于XHTML文档 html(val):设置每一个匹配元素的html内容.这个函数不能用于XML文档.但 ...

  10. c#中常用的异常类型

    c#中异常捕获catch{}常用的异常类型 Exception 类   描述 SystemException 其他用户可处理的异常的基本类  ArgumentException 方法的参数是非法的  ...