如何在 SSIS 包中创建错误日志或自定义错误日志?

发布于 2024-11-03 06:52:24 字数 193 浏览 3 评论 0原文

我正在研究 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撧情箌佬 2024-11-10 06:52:24

这是在 SSIS 中配置日志记录功能的一种方法。在此示例中,我将发送邮件任务配置为失败,并启用了基于 SQL Server 的日志记录,该日志记录将在包失败时存储 OnErrorOnTaskFailed 消息。您可能还会感兴趣其他一些活动。在我工作过的项目中,这两项任务帮助我识别了 SSIS 包中发生的大多数问题。

分步过程:

  1. 本示例中的 SSIS 包包含一个发送邮件任务,其配置如屏幕截图 #1 中所示。它被配置为失败,因此我们可以在日志表中看到一些错误消息。
  2. 单击 SSIS 包。
  3. 在菜单上,选择 SSIS -->正在记录...请参阅屏幕截图#2
  4. 在“配置 SSIS 日志:”对话框中,选择提供程序类型并单击“添加”。我选择 SQL Server 作为本示例。选中名称复选框并在配置列下提供数据源。这里SQLServer是连接管理器的名称。 SSIS 将在您选择的数据库中创建一个名为 dbo.sysssislog 的表和存储过程 dbo.sp_ssis_addlogentry 。请参阅下面的屏幕截图#3
  5. 如果您需要捕获错误,请选中OnErrorOnTaskFailed 复选框。请参阅下面的屏幕截图#4
  6. 数据流任务中的示例包执行如下面的屏幕截图#5所示。
  7. 下面的屏幕截图 #6 显示了日志表 dbo.sysssislog 的示例输出。我只显示了几列ideventsourcemessage。表中还有其他列。消息列包含错误消息,在本例中,发送邮件任务中提到的服务器名称是错误的。源列包含失败的任务。在本例中,包名称为 SSISLoggingExample,发送邮件任务名为 Email Task。错误消息将从任务级别冒泡到包级别。因此,错误消息会在任务和包级别记录两次。

希望有帮助。

屏幕截图 #1:

1

屏幕截图 #2:

2

屏幕截图 #3:

3

屏幕截图 #4:

4

屏幕截图 #5 :

5

屏幕截图#6:

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:

  1. SSIS package in this example contains a Send Mail Task configured as shown in screenshot #1. It is configured to fail so we can see some error messages in the log table.
  2. Click on the SSIS package.
  3. On the menus, select SSIS --> Logging... Refer screenshot #2.
  4. On the Configure SSIS Logs: dialog, select the provider type and click Add. I have chosen SQL Server for this example. Check the Name checkbox and provide the data source under Configuration column. Here SQLServer is the name of the connection manager. SSIS will create a table named dbo.sysssislog and stored procedure dbo.sp_ssis_addlogentry in the database that you selected. Refer screenshot #3 below.
  5. If you need to capture the errors, select the checkbox OnError and OnTaskFailed. Refer screenshot #4 below.
  6. Sample package execution within data flow task is shown in screenshot #5 below.
  7. Sample output of the log table dbo.sysssislog is shown in screenshot #6 below. I have only displayed few columns id, event, source and message. 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:

1

Screenshot #2:

2

Screenshot #3:

3

Screenshot #4:

4

Screenshot #5:

5

Screenshot #6:

6

还不是爱你 2024-11-10 06:52:24

在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文