Share via


ScriptObjectModel.Log Method

Logs an entry to all enabled log providers.

Namespace:  Microsoft.SqlServer.Dts.Tasks.ScriptTask
Assembly:  Microsoft.SqlServer.ScriptTask (in Microsoft.SqlServer.ScriptTask.dll)

Syntax

'Declaration
Public Sub Log ( _
    messageText As String, _
    dataCode As Integer, _
    dataBytes As Byte() _
)
'Usage
Dim instance As ScriptObjectModel
Dim messageText As String
Dim dataCode As Integer
Dim dataBytes As Byte()

instance.Log(messageText, dataCode, dataBytes)
public void Log(
    string messageText,
    int dataCode,
    byte[] dataBytes
)
public:
void Log(
    String^ messageText, 
    int dataCode, 
    array<unsigned char>^ dataBytes
)
member Log : 
        messageText:string * 
        dataCode:int * 
        dataBytes:byte[] -> unit 
public function Log(
    messageText : String, 
    dataCode : int, 
    dataBytes : byte[]
)

Parameters

  • dataCode
    Type: System.Int32
    A field available for numeric data to be logged.
  • dataBytes
    Type: array<System.Byte[]
    A field available for binary data to be logged.

Remarks

Use the #ctor(Connections, VariableDispenser, IDTSComponentEvents, IDTSLogging, Object, String, String) method of the Dts object in Script task code to perform logging to any log providers that are enabled.

Examples

The following sample of code for use inside a Script task demonstrates logging from the Script task by recording a value that represents the number of rows processed.

[Visual Basic]
Public Sub Main()

    Dim rowsProcessed As Integer = 100
    Dim emptyBytes(0) As Byte

    Try
        Dts.Log("Rows processed: " & rowsProcessed.ToString, _
            0, _
            emptyBytes)
        Dts.TaskResult = ScriptResults.Success
    Catch ex As Exception
        'An error occurred.
        Dts.Events.FireError(0, "Script Task Example", _
            ex.Message & ControlChars.CrLf & ex.StackTrace, _
            String.Empty, 0)
        Dts.TaskResult = ScriptResults.Failure
    End Try

End Sub