cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

.NET SDK Logging Configuration

No ratings

The .net-sdk can be configured to emit very detailed debugging and diagnostic information to a log file during execution. The .net-sdk uses the standard .NET System.Diagnostic infrastructure for Logging, as such, all configuration of the .net-sdk logger is done via the standard .NET Logging configuration system.

  • By default, Logging is configured via the standard .NET “App.config” file.
  • Log messages can be routed to any standard .NET TraceListener. Optionally, ThingWorx provides a FixedFieldTraceListener which can be used to output log messages to a file. The use of the ThingWorx provided FixedFieldTraceListener is recommended.
    • The FixedFieldTraceListener when configured will automatically create a "logs" directory in the same location as (a sibling to) the running executable file (.exe). This "logs" directory will contain the log files.
  • Every .NET Class can be configured as a specific “Trace Source” which emits log messages. It is recommended to add at least the following Trace Sources to your App.config file to receive the most useful amount of information:

    • com.thingworx.communications.client.BaseClient
    • com.thingworx.communications.client.ConnectedThingClient
    • com.thingworx.communications.client.things.VirtualThing
    • com.thingworx.communications.client.TwApiWrapper
    • com.thingworx.communications.client.things.filetransfer.FileTransferVirtualThing
    • com.thingworx.communications.client.things.contentloader.ContentLoaderVirtualThing

The amount of information emitted can range from very low level Trace messages (the Verbose setting) to nothing at all (the Off setting). The “SourceLevels Enumeration” can be used to control how much information is written out to the log file. For reference, this is the

<add name="SourceSwitch" value="Information" /> element in the sample below.

Below is sample App.config file.

<?xml version="1.0" encoding="utf-8"?>

<configuration>

    <system.diagnostics>

      <sources>

        <source name="com.thingworx.common.utils.JSONUtilities" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch" >

          <listeners>

            <add name="file" />

          </listeners>

        </source>

        <source name="com.thingworx.communications.client.TwApiWrapper" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch" >

          <listeners>

            <add name="file" />

          </listeners>

        </source>

        <source name="com.thingworx.communications.client.BaseClient" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch" >

          <listeners>

            <add name="file" />

          </listeners>

        </source>

        <source name="com.thingworx.communications.client.ConnectedThingClient" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch" >

          <listeners>

            <add name="file" />

          </listeners>

        </source>

        <source name="com.thingworx.communications.client.things.contentloader.ContentLoaderVirtualThing" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch" >

          <listeners>

            <add name="file" />

          </listeners>

        </source>

        <source name="com.thingworx.communications.client.things.filetransfer.FileTransferVirtualThing" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch" >

          <listeners>

            <add name="file" />

          </listeners>

        </source>

        <source name="com.thingworx.communications.client.things.VirtualThing" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch" >

          <listeners>

            <add name="file" />

          </listeners>

        </source>

        <source name="com.thingworx.metadata.annotations.MetadataAnnotationParser" switchName="SourceSwitch" switchType="System.Diagnostics.SourceSwitch" >

          <listeners>

            <add name="file" />

          </listeners>

        </source>

      </sources>

      <switches>

        <add name="SourceSwitch" value="Information" />

      </switches>

      <sharedListeners>

        <add name="file" type="com.thingworx.common.logging.FixedFieldTraceListener, thingworx-dotnet-common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" initializeData="false"/>

      </sharedListeners>

      <trace autoflush="true" indentsize="4" />

  </system.diagnostics>

</configuration>

Comments

Hi ,

I have following two questions related to log.

1. Is there any way we can configure the log file name? or by any means we can provide the file name so that I can have control on the file name at least?

 

2. At present it generates only one log file and logs all information in it. Can we provide separate log file for each thing?

 

 

One more 

3. Is there any file size limit for the log file? 

Version history
Last update:
‎Nov 17, 2015 01:59 PM
Updated by:
Labels (1)