Save infolog messages using listeners

I had to recall couple days ago how to save the infolog content to the Windows Event Log or to a file on disk. This can be done now in 2012 very easy with the help of listeners. If you want to read more on this, you can find the details at https://msdn.microsoft.com/en-us/library/system.diagnostics.tracelistener%28v=vs.110%29.aspx.

So, to do this you just edit your Ax32.exe.config file (or if this file doesn't exist near the Ax32.exe app file, just create it) and append the following content:

<configuration>

  <system.diagnostics>
    <trace autoflush="true"/>
    <sources>
      <source name="Microsoft.Dynamics.Kernel.Client.DiagnosticLog-Infolog"
              switchValue="Information">
        <listeners>
          <add name="EventLog" 
               type="System.Diagnostics.EventLogTraceListener" 
               initializeData="Dynamics Trace Infolog"/>
          <add name="TextFile" 
               type="System.Diagnostics.TextWriterTraceListener" 
               initializeData="DynamicsTraceInfologTrace.log" 
               traceOutputOptions="DateTime"/>
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

</configuration>

3 comments:

  1. You might also be interested in my more general article about tracing: http://dev.goshoom.net/en/2014/06/instrumentation-and-tracing/

    ReplyDelete
  2. Hi Martin,

    Thanks for reminding that - your post is very explanatory regarding this topic (I recall now reading sometime in the last year your post).

    ReplyDelete
  3. Hi Martin,

    Thanks a lot for knowledge sharing.
    Very interesting article.

    Thanks!
    Atul

    ReplyDelete