Home > Dynamics CRM > CRM – Callouts with simple text logging

CRM – Callouts with simple text logging

Below is an example of how you could log the callout information from CRM when executed. If you would like to do more extensive logging then I suggest you check out Log4Net (http://logging.apache.org/log4net/).
 
You will need to set the appropriate security settings to the Create.txt file so it can be accessed by your custom code. The folder CRM_SDK_Drop should be created first – this can be named anything you like.
 
public override PreCalloutReturnValue PreCreate(CalloutUserContext userContext,
                         CalloutEntityContext entityContext,
                         ref string entityXml,
                         ref string errorMessage)
{
   TextWriter log = TextWriter.Synchronized(
     File.AppendText(@"C:\CRM_SDK_Drop\Create.txt"));
   log.WriteLine("PreCreate");
   log.WriteLine("ObjectType: " +
     entityContext.EntityTypeCode.ToString());
   log.WriteLine("ObjectId: " + entityContext.InstanceId.ToString());
   log.WriteLine("CreatorId: " + userContext.UserId.ToString());
   log.WriteLine();
   log.Close();

   return PreCalloutReturnValue.Continue;
}
Advertisements
Categories: Dynamics CRM
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: