3

I was wondering if it is possible to write to the trace logs of a CRM 365 org from within a C# console application. I can and have done this successfully with a plugin, but haven't been able to find much information on writing to the trace log from a console application.

Figured I'd ask here, before I just use the orgservice to create a record in an entity and add the data that way.

snapplex
  • 851
  • 3
  • 13
  • 27

2 Answers2

2

I don’t think you can do it.

plugintracelog EntityType is supporting GET & DELETE only, no POST support. Also every single attribute is read-only. That being said it is an internal only use entity. Especially for plugins & WFs.

So create a custom entity & log everything.

Btw, Still you can mock it by implementing interface ITracingService.

  • 1
    I've tried to implement a custom log, but then there are different places to check for errors (1) Plugin Trace Log for Workflows & Plugins; and (2) Custom Log Entity for other exceptions. I tried to write workflow errors to the custom entity, but if there is an exception the transaction is rolled back and the error is lost. It would be nice to have a common area where errors / warnings can be written – jasonscript Oct 11 '18 at 06:27
0

Although I have never used it, the Microsoft.Xrm.Tooling.Connector namespace has some ability to configure tracing via the TraceControlSettings class, and other trace-related classes that the first link shows.

However, the example in this post indicates that it's for external tracing (i.e. to a file), rather than using the plugin trace mechanism.

Another commentary: Use Trace not Console

Aron
  • 3,877
  • 3
  • 14
  • 21