We help IT Professionals succeed at work.

How to create Error Log inside the SSIS Package ??

Medium Priority
513 Views
Last Modified: 2012-05-11
I am working on SQL 2008 - SSIS Package. I am executing the package from C# Code. Its 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. ??
Comment
Watch Question

Commented:
if you are calling the ssis package from the command line you may use the -L option to get the log as explained in this link
 http://msdn.microsoft.com/en-us/library/ms162810.aspx

also this link will be very helpful for you if you want to log the ssis package activities within package..

http://msdn.microsoft.com/en-us/library/ms140246.aspx
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Alpesh PatelSolution Architect at TCS (SAFe®Agilist, TOGAF® Foundation, PSM I®, MCP, MCSD)
CERTIFIED EXPERT

Commented:
There are different events. Using those events you can Create a  Log.

There are events like Error, Warning, PreExecute ,Prost Execute is there. SAve the each row for step.
chokkaStudent

Author

Commented:
tigin44 : Thank you for comment. I mentioned on my Post clearly - I am calling SSIS Package from C# Source Code.

Below is the Source Code for invoking the SSIS Package !!!
DTSExecResult pkgResults = new DTSExecResult();
        try
        {
            string strSourceConn = @"C:\SourceFile\File1.csv";
            string pkgLocation = @"C:\SSIS\SSIS\SSIS\Package.dtsx";
           
            Package pkg;
            Microsoft.SqlServer.Dts.Runtime.Application app;

            app = new Microsoft.SqlServer.Dts.Runtime.Application();
            pkg = app.LoadPackage(pkgLocation, null);

            pkg.Variables["sSorceFileName"].Value = strSourceConn;
            
            pkgResults = pkg.Execute();
            Response.Write(pkg.ExecutionResult);
        }
        catch (Exception ex)
        {
            Response.Write(ex.InnerException.Message);
        }

Open in new window

chokkaStudent

Author

Commented:
I kept a Script Task which is connected to DataFlow.

Inside the Script Task, I wrote

    MessageBox.Show(Dts.Variables.Contains("sDestConnStr").ToString());
            MessageBox.Show(Dts.Variables.Contains("sSorceFileName").ToString());
            MessageBox.Show(Dts.Variables.Contains("sTableName").ToString());

Message Box Pops up and shows - False

So, Values which i am passing from C# Source Code is not reaching the Data Flow Task
Can I ask one quick question? Is the variable in the package suppose to be "sSorceFileName"? or is it misspelled in both places?
chokkaStudent

Author

Commented:
SQL Sergent Mike - It is supposed to be sSorceFileName

and we are following the same name every where !!!

Reason behind sSorceFileName was, one of our developer written the variable name every where ..! And i have to follow footsteps of my existing developer !!!
chokkaStudent

Author

Commented:
Thank you
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.