Step 1: Commerce Server 2002 Pipeline Logging and Debugging

In this step you will learn how to enable pipeline logging on the system and insert custom logging scripts to save the pipeline contents to a file.

To enable pipeline logging

To insert a custom logging script

Sample Scriptor Code

To enable pipeline logging

  1. In the Solution Explorer - NorthwindTraders window, right-click the Web.config file, and then click Open.
  2. Locate the <pipelines> section, in the <pipeline> tag of the pipeline on which you want to enable logging, and insert the command loggingEnabled="true" at the very bottom of the pipeline record (before the end tag of the desired pipeline).

Ee810304.note(en-US,CS.20).gifNotes

  • By default, the pipeline output log files are stored in the <Project Name>/pipelines/log folder.
  • The output log files are broken apart by the UserID (GUID) of the user whose session initiated the given pipeline.

To insert custom logging script

  1. In the Solution Explorer - NorthwindTraders window, expand the Pipelines folder, and then double-click the file basket.pcf. The Commerce Server Pipeline Editor starts.

    Ee810304.note(en-US,CS.20).gifNote

    • If you do not see the Pipelines folder, click Show All Files, right-click the Pipelines folder, and then click Include in Project.
  2. In the Commerce Server Pipeline Editor window, right-click any of the pipeline states after the QueryCatalogInfo and RequiredProdInfo components, point to Insert Component, and then click After.

  3. In the Choose a component dialog box, select Scriptor from the components list, and then click OK.

  4. In the Commerce Server Pipeline Editor window, double-click the newly added Scriptor component.

  5. In the Component Properties dialog box, click Edit for internal scriptor and insert the code provided below, or select external and specify the log file location to which you will save pipeline contents.

  6. In the Component Properties dialog box, in the Config box, type filename=c:\orderdump.log, and then click the Component Properties tab.

  7. In the Component Properties dialog box, on the Component Properties tab, in the Label box, type OrderDump.

  8. Click OK.

  9. To save the pipeline, click Save on the toolbar.

The next time youview the basket page and the basket.pcf pipeline is executed, an output file will be placed in the location specified (c:\orderdump.log) that will contain all of the parameters from the specified dictionary.

Sample Scriptor Code

Following is sample code that can be used for internal scripting by the Scriptor pipeline component:

' DumpOrder is a simple example of building a component using VBS and scriptor
'
' To use dumporder, configure a Pipeline using one of the available 
' Pipeline Editors.
' Set the Language to VBScript, choose File and set the file to DumpOrder.vbs 
' (this file).
'
' In addition, this script assumes you set the filename parameter to a
' valid filename for output. The directory the output file is written to 
' must be set up to
' have write access via the user your IIS is running as.
'
' For example, you could set
' filename=c:\orderdump.log
' in the Parameters control.
' 
' This would assume your IIS user can write to c:\
'
function mscsexecute(config, orderform, context, flags)

   Set fs = CreateObject("Scripting.FileSystemObject")
   Set a = fs.CreateTextFile(config.filename, True)

   DumpOrderForm orderform, a

   a.Close

    mscsexecute = 1

end function

sub DumpItem(byRef item, byRef a)

   ' Dump all key/value pairs from a dictionary
   for each key in item
      on error resume next
      a.WriteLine("      Key [" + key + "] {" + TypeName(Key) + "} Value [" + _
            cstr(item.Value(key)) + "] {" + TypeName(item.Value(Key)) + "}")
      if err.number > 0 then 
         if err.number = 450 then 
            DumpItem key, a
         else
            a.writeline " *** ERROR in DumpItem # " & CStr(Err.Number) & _
                        " " & Err.Description
         end if
      end if
   next

end sub

sub DumpItems(byRef items, byRef a)

   'Iterate over List of Dictionaries, dump each dictionary
   n = 1
   for each item in items
      on error resume next
      a.WriteLine("   Item " + cstr(n))
      if err.number > 0 then a.writeline " *** ERROR in DumpItems # " & _
            CStr(Err.Number) & " " & Err.Description
      DumpItem item, a
      n = n + 1
   next

end sub

sub DumpList(byRef list, byRef a)

   'Iterates over list, write out each item and type
   for each item in list
      on error resume next
      a.WriteLine("   Value [" + item + "] {" + TypeName(item) + "}")
      if err.number > 0 then
         if err.number = 450 then 
            a.WriteLine(" ")
            a.WriteLine("   Start Dictionary")
            DumpItem item, a
            a.WriteLine("   End of Dictionary")
            a.WriteLine(" ")
            
         else
            a.writeline " *** ERROR in DumpList # " & CStr(Err.Number) & _
                        " " & Err.Description
         end if
      end if
   next

end sub

sub DumpOrderForm(byRef orderForm, byRef a)

   a.WriteLine("** Orderform Contents **")

   for each key in orderForm

      if VarType(orderForm.Value(key)) <> vbObject then

         ' Dump out top level items
         a.WriteLine("Order Key [" + key + "] {" + TypeName(Key) + "} Value [" + _
                     cstr(orderForm.Value(key)) + "] {" + _
                     TypeName(orderForm.Value(key)) + "}")
      
      elseif key = "Items" then
      
         ' Dump out Items List
         a.WriteLine("Items List")
         DumpItems orderForm.Value(key), a
         a.WriteLine("End of Items List")
         a.WriteLine(" ")

      elseif key = "_Verify_With" then
         ' Dump out _Verify_With Dictionary
         a.WriteLine(" ")
         a.WriteLine("Order Key is [_Verify_With] Start Dictionary")
         DumpItem orderForm.Value(key), a
         a.WriteLine("End of Dictionary")
         a.WriteLine(" ")

      else
         ' Some object, assume it is a list
         a.WriteLine(" ")
         a.WriteLine("Order Key is [" + key + "]" + " Start List")
         on error resume next
         DumpList orderForm.Value(key), a
         if err.number > 0 then
            if err.number = 438 Then
               if TypeName(orderForm.Value(key)) = "IContentList" then
                  a.writeline " *** unable to write the contents of a " & _
                              TypeName(orderForm.Value(key)) & " with " & _
                              orderForm.Value(key).Count & " rows."
               end if
            else
               a.writeline " *** ERROR in DumpOrderForm # " & _
                           CStr(Err.Number) & " " & Err.Description
            end if 
         end if
         a.WriteLine("End of List")
         a.WriteLine(" ")

      end if

   next

   a.WriteLine("** End of Orderform Contents **")

end sub

Copyright © 2005 Microsoft Corporation.
All rights reserved.