Display wrapper.log file in Ignition Project?

I have a need to display the wrapper.log file from the Ignition server in a project running on that server…

Has anyone done this before? How should I do this? Currently I am the Admin so I RDP into the system and look at the file when I need something, but I want others to be able to see this log file as well, without giving them admin access to the server.

Thanks

You can use system.file.readFileAsString() to grab the text from the wrapper.log file, then it’s up to you as far as how you display it in the project. You will need to make sure that your client machines have access to the server’s files. You can do this by individually mapping a drive to the server’s ignition directory on each client machine, or you can follow the tutorial in our manual to give the gateway access to a network share, after which you can regularly save the wrapper.log file out to that share so your clients can pick it up.

Check out this section to learn about giving the gateway access to a network share: Tutorials & Helpful Tricks > Mapping a Network Drive

Sharing files across a network is usually an IT organization’s responsibility so you may need to get help and/or permission to do this.

Here’s another idea:

Write a Gateway Timer Script that runs once a minute (or however frequent you want) that uses system.file.readFileAsString() to read the wrapper.log file from the server.

Then write the wrapper.log string contents to a memory SQLTag. Then you can easily access the wrapper.log string content easily in the client by reading the memory tag.

The wrapper.log file is too big for a memory tag. A memory tag probably has a character limit. So here’s a script I wrote to get the last 64,000 characters of a wrapper.log file and write it to the wrapper memory tag. I then viewed the wrapper.log content in the client by binding the wrapper memory tag to the text property of a Document Viewer component.

path = "C:\\Program Files\\Inductive Automation\\Ignition\\logs\\wrapper.log"
content = system.file.readFileAsString(path)
if len(content) > 64000:
	content = content[-64000:]
system.tag.write("[default]wrapper",content)

Remember that this script runs on the server so the clients don’t need access to a hard drive.

Best,

nmudge,

when you did this was there anything odd happening to your wrapper.log, like it stopped logging? The OP called in on this issue and his wrapper.log file stopped logging because it was open in another application and Ignition created another wrapper.log in the Ignition directory and started logging there.

It would be great if this worked, but I would be worried about some adverse reaction to accessing the file.

I did not have a problem.

Update: I added another Event Timer Script that writes to the wrapper.log file every 0.25 seconds to see if it would cause any problems for the Event Timer Script that reads the wrapper.log file every 10 seconds. This caused no problem. This is on a computer using Windows 8.1.

Update: I changed the Event Timer Script that writes to the wrapper.log file to run every millisecond instead of 0.25 seconds to see if this would cause any problems for the Event Timer Script that that reads the wrapper.log file every 10 seconds. It didn’t cause any problem, still works fine.

Did the user have the wrapper.log file open in another application on the server like a text editor?

A couple developers from Perfect Abstractions created a free project that displays the Wrapper.log file in a client or designer. It can be a stand alone project or added to existing projects.

Check it out here: nickmudge.info/post/view-the-ign … -or-client

1 Like

Hi Nick
Do you have a copy of the project displaying wrapper file ? Unfortunately the link does not work anymore :frowning:

Nick hasn’t been doing Ignition stuff for a while, but here’s the link from the wayback machine.

https://web.archive.org/web/20190423092831/http://nickmudge.info/post/view-the-ignition-wrapper.log-file-in-the-designer-or-client

1 Like

thanks Jordan i appreciate your help

@JordanCClark this wrapper display works very well but i would love to understand how it exactly work and i wonder how far you can help me.
In the event gateway event it import os library
1 any idea why getcwd() function is not defined inside os library ? i could not find it
2 any idea what is os$py.class - can it possibly contain the definition of getcwd()?
Regards

An implementation detail in jython of the standard library's os module. Don't muck around in the standard library or you will break it. It is a delicate combination of native python with java blended in.

1 Like

In general, you should use java’s file handling instead of python’s.

1 Like

yes i only looked from curiosity and i know any change will break it and what is even worse it might not be easy to find out about it unless it points explicitly to the function broke during error message…

Jython is an open-source project. Go wild.

1 Like

thanks for that great resource. So am i correct saying that jython scripting in Ignition is based on the specific version of that open-source project + Ignition added system library for various useful functionality. Does it sound about right or is it a lot more complex?

IA does have some patches to jython, but not many. The published sources are a good guide to what really is running in Ignition.

1 Like