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

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

How to read ".log" file in thingworx

mlohokare
5-Regular Member

How to read ".log" file in thingworx

I have ".log" file on server and want to read that file and take that data into grid.

Did someone already worked on reading ".log"file in ThingWorx?

I came across "CSV" parser extension which can be used to read .xls and .csv files.but I am not sure about "log" file.

Any help is appreciated.

Regards,

Mahesh

9 REPLIES 9

It depends on the format of the Log file content, log extension in itself isn't a problem.

mlohokare
5-Regular Member
(To:CarlesColl)

Hi Carles,

The log file which I am working on is having spaces and a tab in it instead of ", {comma}, which might not work with CSV parser.

Below is the sample content,

Mon Jun 13 15:10:52 2016 [7548] [DEBUG  ]configuration doc opened OK.
Mon Jun 13 15:10:52 2016 [7548] [DEBUG  ]handling req_id={Foo}
Mon Jun 13 15:10:52 2016 [7548] [DEBUG  ]matches_found={1}
Mon Jun 13 15:10:52 2016 [7548] [DEBUG  ]got content OK

Please suggest.

There's a Code Snippet to read raw TXT files, you may try with it and split lines.

Also you may try to pass the "tab" char as the CSV field separator.

Where is the code snippet ?

To load a text from a FileRepository:

var text = Things["file_repository_name"].LoadText({ path: "file_path_name" });

Please find my code snippet.

var text = Things["FileThingTemplate"].LoadText({path:'D:\IOT\Sealed_Air\test.txt'});

Where FileThingTemplate is the template implemented by my FileThing. FileThingTemplate tags FileRepository. I am not able to load the file. I am getting the below message:

TypeError: Cannot call method "LoadText" of null (MyFileReader#19)

Please help.

Alternatively you can use REGEX in your service to parse specific elements. Its syntax seems complex on the first glimpse but there are good tutorials and cheat sheets in the wild.

Hi all,

  I have doubt, Actually I have to get properties from logger file using java code + that properties will store it in Thing COmposer inside thing or ThingTemplate. If u have idea Can you please tell me...

dcbb
1-Newbie
(To:dcbb)

Hi All,

Can you please How to get Properties from .log file using java code...the properties like this

04-Jul-2016 17:03:06.422 INFO [main] COMPLETED=         06/22/2016 07:15PM

04-Jul-2016 17:03:06.422 INFO [main] SPControl v=               10.0.8

04-Jul-2016 17:03:06.422 INFO [main] CURRENT_LOG_CSF3=            250

04-Jul-2016 17:03:06.422 INFO [main] UPLOAD_COUNTER=          28

04-Jul-2016 17:03:06.422 INFO [main] LAST_APPLICATION_FILE=             C:\Test\test.txt

04-Jul-2016 17:03:06.422 INFO [main] LAST_UPDATE==           04-Jul-2016 17:03:06.422

Top Tags