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

Writing to ThingWorx logs via REST API

Highlighted
Regular Member

Writing to ThingWorx logs via REST API

Hi everyone,

 

ThingWorx provides the capability to write arbitrary messages to log entities (e.g. CommunicationLog, ApplicationLog, ScriptLog, etc.) using the REST API.

 

As we prepare for the rollout of the next version of ThingWorx, we would like to understand if anyone is actually using the REST API to write to logs.

 

If so, how are you using it?

 

If not, we are considering removing this capability in order to focus on providing and maintaining other great functionality.

 

Thanks for your feedback.

6 REPLIES 6

Re: Writing to ThingWorx logs via REST API

Hi,
you could solve this by implementing an extension. Define your own Shape with some services. Within these services you can address your required logger.

 

Logger APP_LOGGER = LogUtilities.getInstance().getApplicationLogger("sublogger-name");
Logger CONFIG_LOGGER = LogUtilities.getInstance().getConfigurationLogger("sublogger-name");

 

Create a thing, add your shape. Now can use this thing via REST to report into specific logger.

Re: Writing to ThingWorx logs via REST API

This may help: import attached extension.
Create a thing name 'MyLogger' using shape 'IF.LoggerShape'.
LoggerThing.png
Now you can try directly from Javascript:
 
Things['MyLogger'].ApplicationInfoLog({
logger: "Foo" /* STRING */,
message: "Hello" /* STRING */
});
Our via REST: you need to adjust hostname (and thing-name).
http://hostname:8080/Thingworx/Things/MyLogger/Services/ApplicationInfoLog
POST body like:
{
"logger"": "Foo"
"message"": "Hello via REST"
}

 

LoggerSOAPUI.png

 

Result should be like this:

LoggerOutput.png

 

Regards,

Marcus

Re: Writing to ThingWorx logs via REST API

Hi Walter, what is the API you're referring to?

 

 

Re: Writing to ThingWorx logs via REST API

Hello @Walter_Haydock,

 

I've never seen it used on any project. The opposite use case (i.e. streaming ThingWorx logs into external systems) would make more sense IMHO.

 

/ Constantine

Re: Writing to ThingWorx logs via REST API

In addition to my question, here's the reason why I ask.

1. From an "I want to write to a log" usecase, the preferred way is to use in the ThingWorx services a "logger.warn" statement (or similar), which is usually used to debug service functionality. Since ThingWorx is REST capable OOTM, this will also result in an user's capability to call a service via REST to be capable to write in any of the logs, indirectly

 

In addition to the snippet above, each of the logs, have a service, called 

Logs["ApplicationLog"].Write({    level: undefined /* STRING */,    origin: undefined /* STRING */,    message: undefined /* STRING */});

That would allow direct writing to the any of the logs.

 

Even if we stop supporting the direct route, the user would still be capable to write to the logs, indirectly.

 

 

Re: Writing to ThingWorx logs via REST API

I support Constantine's feedback.

I remember lots of RFPs' that asked us to prove "we can output/send logs to a central logging system" (eg: Cigna).

That was/is a problem, since in the product we don't have an event that would allow us to intercept the message and call an external API. We always would need to resort to workarounds, which are not so nice in some cases.

 

 

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________