# System.util.logger stopped working after moving to another library

**URL:** <https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [July 26, 2023, 3:17pm UTC](https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950 "2023-07-26T15:17:03Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [July 26, 2023, 3:17pm UTC](https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950/1 "2023-07-26T15:17:03Z")

</div>

Hey all, I had the block of code below working without issue.

```auto
'''
LogRestInfo is a function that logs a given message as an informational log if informational messages are enabled.
If printing to console is also enabled, it prints the message to the console.

@param msg: The message to be logged.
'''
def LogRestInfo(msg):
	if showInfoMessages:
		logger = system.util.logger("EpicorRest")
		logger.info(msg)
		if printToConsole:
			print(msg)
		#endif	
	#endif
#End LogRestInfo()

```

I moved the code from my EpicorFuncs library to one that was more generic for use across multiple libraries called EpicorRest. I am still getting output from that method to the Console and Script Console but not the logger anymore. All I did was move it from one library to the other trying to refactor and I can't figure out why it's being a pain in my rear.

My global variables that control the debug output at the top of the EpicorRest library this LogRestInfo method is contained in are set as follows.

```auto
# These variables control debugging output level
showInfoMessages = True
showWarnMessages = True
printToConsole = True

```

When I call a method such as EpicorActive in my EpicorFuncs library EpicorRest.LogRestInfo fires and everything but the logger works.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b643e06cfd41265fd1bb154881db58586310f135.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/8/483c3b09ab744e11d5921d24169cffd0cfdd3a86.jpeg)

Any help and direction is appreciated. Thank you!

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 26, 2023, 3:21pm UTC](https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950/2 "2023-07-26T15:21:39Z")

</div>

`system.util.getLogger` does not automatically forward logs to the gateway.

Your logs are, 100% guaranteed, in the _Designer's_ diagnostics/output console, if you're invoking your project library script from the script console.

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [July 26, 2023, 3:22pm UTC](https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950/3 "2023-07-26T15:22:58Z")

</div>

> [@wci.jgiese](#):
>
> ```auto
> logger = system.util.logger("EpicorRest")
> logger.info(msg)
> 
> ```

Wouldn't the above be what pushes my logging info to the gateway? That's what it previously when it still lived in EpicorFuncs with the EpicorActive method.

Our current production instance where all this is working yet

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

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 26, 2023, 3:25pm UTC](https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950/4 "2023-07-26T15:25:31Z")

</div>

No. `system.util.getLogger()` creates a logging object _in the local scope_.

Note the `EpicorRest` in the output console:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/3/83cc3cf32ce674ec64d8467952ca3553bd8ee1e2.png)

`getLogger` is working exactly as designed. If you want your calls to automatically log to the gateway, you have to send them over yourself, e.g. using `system.util.sendMessage`.

---

<div class="post-metadata">

**Author:** ![jcoffman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jcoffman/32/6429_2.png) [@jcoffman](https://forum.inductiveautomation.com/u/jcoffman)\
**Post date:** [July 26, 2023, 3:26pm UTC](https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950/5 "2023-07-26T15:26:18Z")

</div>

To see more about what Paul is talking about, see the [Scripting Docs about "scope"](https://docs.inductiveautomation.com/display/DOC81/Scripting+in+Ignition)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 26, 2023, 3:26pm UTC](https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950/6 "2023-07-26T15:26:51Z")

</div>

The script library is _just a library_. It doesn't automagically rewrite your code from one execution scope to another - it's a _library_, a collection of scripts that **can** be called from multiple places.

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [July 26, 2023, 3:29pm UTC](https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950/7 "2023-07-26T15:29:24Z")

</div>

Right I understand that and I am calling the logging function from EpicorFuncs and passing it what I want it to log.

In EpicorFuncs

```auto
def EpicorActive(res):
	EpicorRest.LogRestInfo('EpicorActive (' + res + ') Called')

```

In EpicorRest

```auto
def LogRestInfo(msg):
	if showInfoMessages:
		logger = system.util.logger("EpicorRest")
		logger.info(msg)
		if printToConsole:
			print(msg)
		#endif	
	#endif
#End LogRestInfo()

```

By passing the params into EpicorRest.LogRestInfo I would then be logging it in scope of EpicorRest no?

---

<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, 3:32pm UTC](https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950/8 "2023-07-26T15:32:26Z")

</div>

No, "scope" is _what application is executing the code_, i.e. Ignition Gateway, Ignition Designer, or Vision Client.

Where does the call to `EpicorActive()` originate?

---

<div class="post-metadata">

**Author:** ![wci.jgiese](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/wci.jgiese/32/50225_2.png) [@wci.jgiese](https://forum.inductiveautomation.com/u/wci.jgiese)\
**Post date:** [July 26, 2023, 3:41pm UTC](https://forum.inductiveautomation.com/t/system-util-logger-stopped-working-after-moving-to-another-library/76950/9 "2023-07-26T15:41:48Z")

</div>

Ahhhhh I follow now. We're talking execution scope, not code scope. I got you now. When I actually get the gateway to throw it from the tag changes I see them so back to where I was this morning.
