Logging with the .NET sdk?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Logging with the .NET sdk?
I'm trying to figure out how to log using the .NET SDK so far the only decent reference I came across is this link below:
.NET SDK Logging Configuration
However when I add this information to the App.config file (part of the file in the link above) I get several different exceptions. If I remove these then it'll compile but then there is no Log file/directory created. (If it is I can't find it anywhere)
<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.ConnectedThingClient" 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>
Hope someone can help!
Solved! Go to Solution.
- Labels:
-
Connectivity
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi guys,
Thanks for your replies, I've managed to figure out the correct App.Configuration code:
<?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="Verbose" />
</switches>
<sharedListeners>
<add name="file" type="com.thingworx.common.logging.FixedFieldTraceListener, thingworx-dotnet-common, Version=5.6.1.1100, Culture=neutral"/>
</sharedListeners>
<trace autoflush="true" indentsize="4" />
</system.diagnostics>
</configuration>
Not sure why it didn't like the last line PublicKeyToken=null" initializeData="false" but all is working now.
Hopefully this is useful to someone else.
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hello,
What are the exceptions that you are seeing when you add the configuration given in that Community post?
Thanks!
Tori
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi Tori,
Hope all is well!, this is first point it breaks!
Kind regards
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi John, if you cannot connect the .NET SDK to the ThingWorx platform you can disable encryption as explained on the .NET SDK Developers Guide (page 20).
client.DisableEncryption(); // replace this line from .NET Dev Guide with one of the below lines.
BaseClient.disableEncryption(); // OR
ConnectedThingClient.disableEncryption();
Let me know if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Heya, unfortunately these made no difference, got the same error.
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
John, I would first revert the "App.config" file to it's initial state or to the one before the logging configuration (maybe also remove thingworx-dotnet-common.dll from the project) to be able to build my project without errors.
Then if you cannot connect to the ThingWorx platform I would use the "BaseClient.disableEncryption();" function.
As an alternative you can start with the examples provided in the the .NET SDK Developers Guide and integrate them into you project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Heya, Sorry maybe we are at crossed wires, I can connect to TW fine with only half of the above App.config file which is fine but if I use the full version (which I assume is what I needed for logging to work) then I get that error.
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
John,
If you use the entire app.config file provided in the example you linked in your original post do you still see the same errors?
Meghan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi guys,
Thanks for your replies, I've managed to figure out the correct App.Configuration code:
<?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="Verbose" />
</switches>
<sharedListeners>
<add name="file" type="com.thingworx.common.logging.FixedFieldTraceListener, thingworx-dotnet-common, Version=5.6.1.1100, Culture=neutral"/>
</sharedListeners>
<trace autoflush="true" indentsize="4" />
</system.diagnostics>
</configuration>
Not sure why it didn't like the last line PublicKeyToken=null" initializeData="false" but all is working now.
Hopefully this is useful to someone else.
John
