• subscribe
December 07, 2009 12:00 AM

SSIS Logging Best Practices

What information should be logged, where should it be logged, and how should it be logged?
SQL Server Pro
InstantDoc ID #103213
Listing 1: Writing Additional Details to a Text File to Be Added to Windows Event Logs
public static void RaiseTheAlarm(string errPath, string LoadName, Boolean writeToEventLog, Exception ex)
{
//irrelevant code removed
StreamWriter ErrorWrite = new StreamWriter(logPath.ToString()  );
            ErrorWrite.WriteLine("There has been an error in the load of " + LoadName);
            ErrorWrite.WriteLine("Exception Message");
            ErrorWrite.WriteLine(ex.Message);
            string errMess = ex.Message; 

            if (ex.InnerException == null)
            {
                if (errMess.Contains("An unknown error has occurred. Please contact the application administrator for further information."))
                {
                    ErrorWrite.WriteLine("This error typically appears when there is a failure with a call to a web service.  Please chack the appropriate WCF service for errors.");
                }
            }
            else
            {
                ErrorWrite.WriteLine("Inner exception: ");
                ErrorWrite.WriteLine(ex.InnerException.Message);
                if ( ex.InnerException.InnerException != null)
                {
                    ErrorWrite.WriteLine("Inner exception: ");
                    ErrorWrite.WriteLine(ex.InnerException.InnerException.Message);
                }
            }
            ErrorWrite.Flush();
            ErrorWrite.Close();
          //irrelevant code removed
}


ARTICLE TOOLS

Comments
  • Bhudev
    2 years ago
    Mar 05, 2010

    This is what, I was looking for. I'm working one of major DW requirements on SSIS, where counting of packages can cross 100 mark. Source can be Web Site, Structural DB tables, Flat files & other formats, which will come from multiple applications. My manager asked to give common framework for Exceptional Handling & which will be better out of Exceptional Handling using SSIS Features vs Using Web Services or using C# APIs.

    As you have discribed why & why not in details, it was really helpfull to me.

You must log on before posting a comment.

Are you a new visitor? Register Here
  • SP1?
    I know there is a SP1 for SQL 2008 R2 available....and there is a "feature pack" as well... ...
  • SQL database mirroring
    I have SQL Server 2008 R2 Enterprise 64bit on Windows 2008 R2 Enterprise 64bit.  Each SQL Server has...
  • Dell Compellent Disk Drive
    Does anybody has experience with Dell Compellent Disk Drive? Basically, this system manages all disk...
  • Sql server performance tuning
    I need to find a tool that help me to optimize sql server,queries,improve the performance and solve ...