# Log custom messages from functions

**URL:** <https://forum.inductiveautomation.com/t/log-custom-messages-from-functions/76933>\
**Category:** Ignition\
**Created:** [July 26, 2023, 8:51am UTC](https://forum.inductiveautomation.com/t/log-custom-messages-from-functions/76933 "2023-07-26T08:51:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [July 26, 2023, 8:51am UTC](https://forum.inductiveautomation.com/t/log-custom-messages-from-functions/76933/1 "2023-07-26T08:51:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![deon.korb](https://avatars.discourse-cdn.com/v4/letter/d/8c91f0/32.png) [@deon.korb](https://forum.inductiveautomation.com/u/deon.korb)\
**Post date:** [July 26, 2023, 8:56am UTC](https://forum.inductiveautomation.com/t/log-custom-messages-from-functions/76933/2 "2023-07-26T08:56:56Z")

</div>

`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](https://docs.inductiveautomation.com/display/DOC81/system.util.getLogger)

---

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [July 26, 2023, 9:04am UTC](https://forum.inductiveautomation.com/t/log-custom-messages-from-functions/76933/3 "2023-07-26T09:04:53Z")

</div>

This is how I am using it-

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/a/1a5b6a80c7f2c520bf5324c94843d06bed4f536f.png)

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?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 26, 2023, 11:36am UTC](https://forum.inductiveautomation.com/t/log-custom-messages-from-functions/76933/4 "2023-07-26T11:36:12Z")

</div>

`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.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 26, 2023, 12:35pm UTC](https://forum.inductiveautomation.com/t/log-custom-messages-from-functions/76933/5 "2023-07-26T12:35:28Z")

</div>

> [@Ajay\_Gupta](#):
>
> but the log gets cleared on Gateway restarts

This should not be happening.

---

<div class="post-metadata">

**Author:** ![Ajay\_Gupta](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@Ajay\_Gupta](https://forum.inductiveautomation.com/u/Ajay_Gupta)\
**Post date:** [July 26, 2023, 7:02pm UTC](https://forum.inductiveautomation.com/t/log-custom-messages-from-functions/76933/6 "2023-07-26T19:02:12Z")

</div>

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?
