简体   繁体   English

如何以编程方式设置SSIS包的日志文件路径

[英]how to set the log file path of the SSIS package programmatically

I am executing SSIS package programmatically using C# and I want to set the log file for the package by reading the path from the web.config file.我正在使用 C# 以编程方式执行 SSIS 包,我想通过从 web.config 文件中读取路径来设置包的日志文件。 I looked at the code from the link http://msdn.microsoft.com/en-us/library/ms136023.aspx .我查看了链接http://msdn.microsoft.com/en-us/library/ms136023.aspx中的代码。 but the package already has logging enabled and file name set to some location, I just need to be able to update the log file path to a different location dynamically by reading from config file.但是该包已经启用了日志记录并将文件名设置到某个位置,我只需要能够通过从配置文件中读取来动态地将日志文件路径更新到不同的位置。 Please let me know how to do this.请让我知道该怎么做。 thanks in advance.提前致谢。

You should be able to modify the ConnectionString property of the ConnectionManager , which can be retrieved from an existing package's Connections property.您应该能够修改ConnectionManagerConnectionString属性,该属性可以从现有包的Connections属性中检索。 For example:例如:

Application app = new Application();
Package p = app.LoadPackage(@"C:\PathToPackage", null);

// LogFileConnection is an existing connection to a log file.
ConnectionManager c = p.Connections["LogFileConnection"] as ConnectionManager;
if (c != null)
    c.ConnectionString = @"C:\SomePathToLogFile"; // Change the file path

p.Execute(); //You should now see events logged to the new file path

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何设置SSIS包项目的构建输出路径目录? - how to set build output path directory of SSIS package project? 如何在log4net中以编程方式更改日志文件路径? - How to change the Log file path programmatically in log4net? 以编程方式执行SSIS程序包 - Executing SSIS package programmatically 如何以编程方式将平面文件连接的连接字符串修改为 SSIS package? - How can I programmatically modify the connection string of a flat file connection to a SSIS package? 如何以编程方式将本地文件路径设置为网页的文件上传器 - how to programmatically set local file path to file uploader of a web page SSIS包路径将是什么? - What will be the SSIS Package Path? 如何以编程方式设置此 xml 文件的物理路径? - How can I set the physical path of this xml file programmatically? 是否可以使用C#将ssis包执行的事件记录到文件中 - is it possible to log events of ssis package execution using c# to a file 如何以编程方式连接SSIS包中的两个数据流任务? - How to connect two data flow tasks in SSIS package programmatically? 如何从以编程方式生成的 SSIS 包中获取 GraphLayout XML - How to get GraphLayout XML from programmatically generated SSIS package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM