Using InvalidPluginExecutionException in Plugin, where is the error logged? RRS feed

  • Question

  • We're using CRM 2013 SP1 RU1 On Premises, and I need to throw an exception in a plugin when an issue occurs.  I'm using InvalidPluginExecutionException which works as expected, but I'd like the error to be logged somewhere.  The plugin is running as PreOperation and Synchronous, and per this article I thought the error would be saved to the Application Log in the Event Log:


    But this doesn't seem to be the case.  I don't want to depend on the user to send me the downloaded log if an issue comes through.  Also I understand the transaction is rolled back so I can't write to a log entity.  So how can I determine or log when an exception is thrown using InvalidPluginExecutionException ?

    Thank you.

    Wednesday, July 29, 2015 3:34 AM

All replies

  • Hello,

    It is correct what is written in article. Error is written to event log of CRM Server and if trace is turned on to trace of CRM Server.

    Dynamics CRM MVP
    My blog

    Wednesday, July 29, 2015 5:15 AM
  • Note that errors are only written by Crm to the application event log if they are not of type InvalidPluginExecutionException. If you want to pass a message back to the user, and log the error, then you'd need to use an InvalidPluginExecutionException and write your own code (System.Diagnostics.EventLog.WriteEntry ) to write the message additionally to the event log

    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Wednesday, July 29, 2015 9:15 AM