Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you enable logging for CrmServiceClient in the Xrm Tooling toolkit?

I'm having issues trying to log in to a CRM Online organization through the use of the latest version of the Xrm Tooling nuget package using the connection string constructor from a custom powershell cmdlet.

I'm receiving a rather unhelpful "Unable to Login to Dynamics CRM" error message and am attempting to enable tracing to troubleshoot but have not been able to enable it by modifying the .dll.config file like the below (taken from an XrmToolbox issue on GitHub):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.diagnostics>
    <trace autoflush="true" />
    <sources>
      <source name="Microsoft.Xrm.Tooling.Connector.CrmServiceClient"
              switchName="Microsoft.Xrm.Tooling.Connector.CrmServiceClient"
              switchType="System.Diagnostics.SourceSwitch">
        <listeners>
          <add name="console" type="System.Diagnostics.DefaultTraceListener" />
          <remove name="Default" />
          <add name ="fileListener" />
        </listeners>
      </source>

      <source name="Microsoft.Xrm.Tooling.CrmConnectControl"
              switchName="Microsoft.Xrm.Tooling.CrmConnectControl"
              switchType="System.Diagnostics.SourceSwitch">
        <listeners>
          <add name="console" type="System.Diagnostics.DefaultTraceListener" />
          <remove name="Default" />
          <add name ="fileListener" />
        </listeners>
      </source>
    </sources>
    <switches>
      <!--
            Possible values for switches: Off, Error, Warning, Info, Verbose
                Verbose:    includes Error, Warning, Info, Trace levels
                Info:       includes Error, Warning, Info levels
                Warning:    includes Error, Warning levels
                Error:      includes Error level
        -->
      <add name="Microsoft.Xrm.Tooling.Connector.CrmServiceClient" value="Verbose" />
      <add name="Microsoft.Xrm.Tooling.CrmConnectControl" value="Verbose" />
      <add name="Microsoft.Xrm.Tooling.WebResourceUtility" value="Verbose" />
    </switches>
    <sharedListeners>
      <add name="fileListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="XRMToolingLogs.log" />
      <!--<add name="eventLogListener" type="System.Diagnostics.EventLogTraceListener" initializeData="XRMTooling" />-->
    </sharedListeners>
  </system.diagnostics>
</configuration>
like image 328
GotDibbs Avatar asked Feb 06 '23 18:02

GotDibbs


1 Answers

I was able to work around this by configuring the listener programmatically through:

Microsoft.Xrm.Tooling.Connector.TraceControlSettings.TraceLevel = System.Diagnostics.SourceLevels.All;
Microsoft.Xrm.Tooling.Connector.TraceControlSettings.AddTraceListener(new TextWriterTraceListener("log.txt"));

Which pointed me to the actual error which was that the CrmServiceClient was expecting a URL with the organization unique name instead of the URL name.

like image 109
GotDibbs Avatar answered Apr 06 '23 00:04

GotDibbs