Freigeben über


Writing to the EventLog from an Orchestration

Please be very careful with how you do this. This can be a disaster in a production environment (Imagine writing millions of messages to an eventlog)! I once saw an environment that was writing customer information in the EventLog (there is a very bad idea as anyone with rights to read the log can get access to that information).

Writing Message Content
Trace and debug messages are also useful for writing out the contents of messages and orchestration variables. This is useful for inspecting intermediate messages produced by multiple transforms and for determining the values of other transient values.

The first step is to add the appropriate variable declarations to the orchestration:

  • stringMessage of type string
  • xmlMessage of type System.Xml.XmlDocument
  • myMessage is the orchestration message whose contents are to be output

After these variables have been declared, add the following code to an Expression shape in your orchestration:

xmlMessage = myMessage;
stringMessage = xmlMessage.OuterXml;
System.Diagnostics.EventLog.WriteEntry("MyBizTalkLogEntry", stringMessage);

The is handy perhaps for you Dev environment but very dangerous for production. 

For more debugging tips please refer to: https://technet.microsoft.com/en-us/library/cc825581(BTS.10).aspx