Execute as “Script Task”.

                var path = (string)Dts.Variables["User::LogFileName"].Value;
                var textToWrite = "<" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") +"> "
                    + (string)Dts.Variables["System::PackageName"].Value + " ("
                    + Dts.Variables["System::VersionBuild"].Value.ToString() + ") : "                   
                    + (string)Dts.Variables["User::LogMsg"].Value + "\r\n";
                System.IO.File.WriteAllText(path, textToWrite);
        private void logMsg(string msg)
        {
            if (bLog)
            {
                var path1 = (string)Dts.Variables["User::LogFileName"].Value;
                var textToWrite = "<" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "> "
                    + (string)Dts.Variables["System::PackageName"].Value + "-"
                    + (string)Dts.Variables["System::TaskName"].Value + ": " + msg
                    + Environment.NewLine;
                System.IO.File.AppendAllText(path1, textToWrite);
            }
        }
Last modified: April 22, 2019

Author

Comments

Write a Reply or Comment