# Gateway logs intermittent, Scrips parse differently at gateway scope

**URL:** <https://forum.inductiveautomation.com/t/gateway-logs-intermittent-scrips-parse-differently-at-gateway-scope/75549>\
**Category:** Ignition\
**Tags:** scripting, vision, ignition81\
**Created:** [June 26, 2023, 7:38pm UTC](https://forum.inductiveautomation.com/t/gateway-logs-intermittent-scrips-parse-differently-at-gateway-scope/75549 "2023-06-26T19:38:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_Starr](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@Jonathan\_Starr](https://forum.inductiveautomation.com/u/Jonathan_Starr)\
**Post date:** [June 26, 2023, 7:38pm UTC](https://forum.inductiveautomation.com/t/gateway-logs-intermittent-scrips-parse-differently-at-gateway-scope/75549/1 "2023-06-26T19:38:17Z")

</div>

I have a tag change script on an OPC tag that is opening a project script from the "Gateway Scripting Project". The script can be called and run from the "Script Console" without error. When the tag change script is run and the logger is working the line { if scanString[0:5] == 'ERROR' } throws a { TypeError: 'NoneType' object is unsubscriptable } failure.

I don't feel like treating a string like a list to look for a substring is a typeError but it's something I can deal with.

What I can't handle is the logger failing to capture anything unless I restart the entire ignition service from windows services. Can anyone tell me how to debug the Gateway logger in 8.1 or of a better way to scrape errors caused by tag change scripts. I try deleting { system\_logs.idb } from { C:\Program Files\Inductive Automation\Ignition\logs } but after a service restart I got the same intermittent behavior sometimes stuff makes it to logger sometimes it doesn't for the same inputs.

FYI I don't want to move the tag change script to a Gateway Event because I have 50 of these tags hence the UDT.

---

<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:** [June 26, 2023, 8:00pm UTC](https://forum.inductiveautomation.com/t/gateway-logs-intermittent-scrips-parse-differently-at-gateway-scope/75549/2 "2023-06-26T20:00:43Z")

</div>

> [@Jonathan\_Starr](#):
>
> I don't feel like treating a string like a list to look for a substring is a typeError

That's because it isn't a string for this error, it is a `None`. Find out why you are getting a `None`. (Share your script?)

Also note that Ignition deliberate suppresses successive identical errors that come from various events. When that is the case, you can usually get all of them by turning the corresponding logger to DEBUG.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Starr](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@Jonathan\_Starr](https://forum.inductiveautomation.com/u/Jonathan_Starr)\
**Post date:** [June 26, 2023, 8:12pm UTC](https://forum.inductiveautomation.com/t/gateway-logs-intermittent-scrips-parse-differently-at-gateway-scope/75549/3 "2023-06-26T20:12:30Z")

</div>

You are on point about the none type error, thank you!

I changed:  
tags.eventscripts.dispatcher  
to DEBUG and got my error to show back up! YAY!

Error is now { TypeError: 'int' object is unsubscriptable }  
New bugs == progress! YAY!

If I put a print statement into the tag change script will it show up in logger and or how do I print to console or logger from such a script?

Thank you for the help.

---

<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:** [June 26, 2023, 8:18pm UTC](https://forum.inductiveautomation.com/t/gateway-logs-intermittent-scrips-parse-differently-at-gateway-scope/75549/4 "2023-06-26T20:18:47Z")

</div>

> [@Jonathan\_Starr](#):
>
> If I put a print statement into the tag change script will it show up in logger

No, just the wrapper log. You need a logger from `system.util.getLogger()` to actually log something yourself. Using the logger's methods, not any form of print.

Consider defining a logger as a top-level variable in a library script in your gateway scripting project to avoid calling system.util.getLogger() in each event.

---

<div class="post-metadata">

**Author:** ![Jonathan\_Starr](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@Jonathan\_Starr](https://forum.inductiveautomation.com/u/Jonathan_Starr)\
**Post date:** [June 27, 2023, 7:18pm UTC](https://forum.inductiveautomation.com/t/gateway-logs-intermittent-scrips-parse-differently-at-gateway-scope/75549/5 "2023-06-27T19:18:11Z")

</div>

@pturmel

I have been able to print strings to log using the system.util.getLogger() command  
But when I ask it to print the currentvalue or [.]tagname I get a return like this:  
TypeError: info(): 1st arg can't be coerced to String

If I try to log a hard coded string it works. How do I get the .info or .warn to show me the value of a tag?

---

<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:** [June 27, 2023, 7:33pm UTC](https://forum.inductiveautomation.com/t/gateway-logs-intermittent-scrips-parse-differently-at-gateway-scope/75549/6 "2023-06-27T19:33:22Z")

</div>

Use the `.infof()` or `.warnf()` methods with a `%s` embedded to perform `printf()` style formatting into a string. Logger methods are java, and are not "duck-typed" like jython.

{ Did you look at any of the examples in the [user manual](https://docs.inductiveautomation.com/display/DOC81/system.util.getLogger)? }
