Log custom messages from functions

Hi,

I want to log custom messages from the functions that I have created so that I can analyze what's happening/happened at times I need to.
Is there any option inbuilt in ignition to do this?

I tried system.util.getLogger("MyLogger") but it only logs inside the designer console which is not what I want.

Then I read about Gateway logs but the log gets cleared on Gateway restarts. So, that is also not suitable for me.
Then read about wrapper log which looks like it keeps log files on the disk which is what I want.
Is there a way that I can use to write to wrapper log files?

I want to avoid to create my own logger program if it is possible. I want the logged information to be persistent. So either logging to a file or database table would work for me.

system.util.getLogger() definitely logs to the gateway. I use it all the time.

Check if you are using it correctly and paste an example.

https://docs.inductiveautomation.com/display/DOC81/system.util.getLogger

This is how I am using it-

Since you use it, are the gateway logs persistent across gateway restarts? How long do they stay? Is their any auto archiving that runs and keeps logs only so far back?

Would you mind sharing how you implement it?

system.util.getLogger logs to whatever scope you are executing in. If that’s the gateway, then it goes to the gateway logs (including wrapper log). The wrapper log files are sized and rotated according to settings in ignition.conf.

If you want to log from the Designer/Client scope and have it end up in the gateway logs you need to send the message there somehow, like using a message handler, and then do the logging in the handler.

4 Likes

This should not be happening.

2 Likes

Let me try using message handler.
Is there a place or way to create a custom config file within ignition project where i can store log messages settings in an xml structure and maintain the log meesages, error code etc externally?
I'd read from this config file in functions where i want to log.

I see in the webdev module you can create text resource( of type xml). what if i don't have webdev installed, where can i create the custom config file?