locked
CRM 2013. C#. Plugin Event Logging. RRS feed

  • Question

  • Hi.

    Trying to catch some events to log.

    EventLog.WriteEntry("CRM Plugin", "Hello world!", EventLogEntryType.Error);

    Plugin starts and finishes fine. But there is no any my event log messages in Win\Application eventlog on the CRM-server. What could be the problem?

    Thanks.




    • Edited by Dismantled Friday, July 11, 2014 9:49 AM
    Friday, July 11, 2014 9:44 AM

Answers

  • There are two likely causes:

    1. The plugin is running in the sandbox. If so, it won't have code access permission to write to the event log
    2. The CRM service account (identity of the CrmAppPool for synchronous plugins, CrmAsyncService identity for asynchronous plugins) doesn't have rights to write to the event log. Normally the account would have the rights to write an event for an existing event source. However, if the event source ('CRM Plugin' in your example) is not registered, then it will attempt to register it, but this needs local admin rights

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

    • Marked as answer by Dismantled Friday, July 11, 2014 10:42 AM
    Friday, July 11, 2014 10:01 AM
    Moderator

All replies

  • There are two likely causes:

    1. The plugin is running in the sandbox. If so, it won't have code access permission to write to the event log
    2. The CRM service account (identity of the CrmAppPool for synchronous plugins, CrmAsyncService identity for asynchronous plugins) doesn't have rights to write to the event log. Normally the account would have the rights to write an event for an existing event source. However, if the event source ('CRM Plugin' in your example) is not registered, then it will attempt to register it, but this needs local admin rights

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

    • Marked as answer by Dismantled Friday, July 11, 2014 10:42 AM
    Friday, July 11, 2014 10:01 AM
    Moderator
  • DavidJennaway,

    Thanks a lot! That helps.

    There were both those problems.


    • Edited by Dismantled Friday, July 11, 2014 10:44 AM
    Friday, July 11, 2014 10:42 AM
  •  You should always check the source before you write the log

    // Create the event source if it does not exist. 
        if(EventLog.SourceExists("CRM Plugin"))
        {
           //...
        }


    ( ';')< "I hate this UI"

    • Proposed as answer by ViN.k.S Wednesday, December 24, 2014 7:06 AM
    • Unproposed as answer by ViN.k.S Wednesday, August 19, 2015 7:46 AM
    Monday, September 1, 2014 6:45 AM