如何在 SSIS 包中创建错误日志或自定义错误日志?
我正在研究 SQL 2008 - SSIS 包。我正在从 C# 代码执行该包。它是简单的平面文件 (.csv) 到 SQL 表。
从 C# 代码中,我得到的执行结果为 SUCCESS
,但在包内事务尚未执行,因此值实际上并未导出。
我需要通过读取日志文件来调试它。
如何在包内创建错误日志或日志文件?
I am working on SQL 2008 - SSIS Package. I am executing the package from C# code. It's simple Flat File ( .csv) to SQL Table.
From the C# code, I get execution result as SUCCESS
but inside the package Transactions have not taken, so values are not actually exported.
I need to debug it, by reading the log file.
How to create Error Log or Log File inside the Package?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是在 SSIS 中配置日志记录功能的一种方法。在此示例中,我将发送邮件任务配置为失败,并启用了基于 SQL Server 的日志记录,该日志记录将在包失败时存储 OnError 和 OnTaskFailed 消息。您可能还会感兴趣其他一些活动。在我工作过的项目中,这两项任务帮助我识别了 SSIS 包中发生的大多数问题。
分步过程:
名称
复选框并在配置
列下提供数据源。这里SQLServer是连接管理器的名称。 SSIS 将在您选择的数据库中创建一个名为 dbo.sysssislog 的表和存储过程 dbo.sp_ssis_addlogentry 。请参阅下面的屏幕截图#3。OnError
和OnTaskFailed
复选框。请参阅下面的屏幕截图#4。dbo.sysssislog
的示例输出。我只显示了几列id
、event
、source
和message
。表中还有其他列。消息列包含错误消息,在本例中,发送邮件任务中提到的服务器名称是错误的。源列包含失败的任务。在本例中,包名称为 SSISLoggingExample,发送邮件任务名为 Email Task。错误消息将从任务级别冒泡到包级别。因此,错误消息会在任务和包级别记录两次。希望有帮助。
屏幕截图 #1:
屏幕截图 #2:
屏幕截图 #3:
屏幕截图 #4:
屏幕截图 #5 :
屏幕截图#6:
Here is one way of configuring logging feature in SSIS. In this example, I have Send Mail Task configured to fail and I have enabled the SQL Server based logging which will store the OnError and OnTaskFailed messages when the package fails. There are other events that could be of interest to you as well. In the projects that I have worked, these two tasks have helped me to identify most of the issues that occur in SSIS packages.
Step-by-step process:
Name
checkbox and provide the data source underConfiguration
column. Here SQLServer is the name of the connection manager. SSIS will create a table nameddbo.sysssislog
and stored proceduredbo.sp_ssis_addlogentry
in the database that you selected. Refer screenshot #3 below.OnError
andOnTaskFailed
. Refer screenshot #4 below.dbo.sysssislog
is shown in screenshot #6 below. I have only displayed few columnsid
,event
,source
andmessage
. There are other columns in the table. Message column contains the error message, here in this case the server name mentioned in the Send Mail Task is wrong. Source column contains the task where it failed. Here in this case, the package name is SSISLoggingExample and Send Mail Task is named as Email Task. Error messages will bubble up from task to the package level. Hence, the error message is logged twice under the task as well as at the package level.Hope that helps.
Screenshot #1:
Screenshot #2:
Screenshot #3:
Screenshot #4:
Screenshot #5:
Screenshot #6:
在 SSIS 中记录错误非常容易。转到事件处理程序选项卡,从下拉列表中选择 OnError。现在,您可以在此处发送有关任何错误的电子邮件,或者您可以开发自己的自定义逻辑将错误记录到数据库或写入文本文件。
此外,您还可以从 SSIS 中现有的日志记录机制中进行选择。单击菜单“SSIS”,您将看到第一个选项“日志记录”,然后您将看到用于记录错误/警告以及您需要的大量信息的不同选项。
It's very easy to log errors in SSIS. Go to Event Handlers tab, select OnError from dropdown. Now here you can send email on any error or you can develop your own custom logic to log error into DB or write to text file.
Also, you can choose from existing logging mechanism available in SSIS. Click on menu "SSIS", you will see first option as Logging then you will see different options to log errors/warnings and whole lot of information you need.