上下文: 我有一个 SSIS 包,它通过执行进程任务调用 C# 控制台应用程序。
C# 程序使用Console.Write("xxx");并Console.Error.Write("yyyy");判断它是否正常工作。
static void Main(string[] args)
{
try
{
//do stuff
Console.Write("xxx");
}
catch (Exception e)
{
Console.Error.Write("yyyy");
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题: 如何在ssis中捕获流程任务的输出?
我尝试过的:
在流程任务表达式中使用控制流中的局部变量设置 StandardOutputVariable 和 StandardErrorVariable。
当我定义 String 变量时,在流程任务完成后两者都是空的。当我定义对象变量时,我尝试运行一个脚本任务并将值转换为字符串数组,但它抛出一个无效的转换异常。
我缺少什么?我不能修改真正的 C# 程序来改变它的记录方式。
我自己通过实验找到了解决方案。
好吧,我缺少的是 standardErrorVariable 的表达式值如何工作。
当我用变量填充 standardErrorVariable 表达式值时,行为是:
use the value of @[User::l_output] as a variable name to use for standardOutput.
它不是 :use this variable to capture the output
所以我有两种解决方案来捕获流程的输出:
@[User::l_output]进程内任务配置(不在espression选项卡中)@[User::l_output]StandardOutputVariable 表达式中的变量,并将变量值设置为我之前声明的变量的其他名称。
