# Logger not logging

**URL:** <https://forum.inductiveautomation.com/t/logger-not-logging/92299>\
**Category:** Ignition\
**Created:** [June 24, 2024, 7:49pm UTC](https://forum.inductiveautomation.com/t/logger-not-logging/92299 "2024-06-24T19:49:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Herbert\_Augustiny](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@Herbert\_Augustiny](https://forum.inductiveautomation.com/u/Herbert_Augustiny)\
**Post date:** [June 24, 2024, 7:49pm UTC](https://forum.inductiveautomation.com/t/logger-not-logging/92299/1 "2024-06-24T19:49:02Z")

</div>

Hi All  
I have a wired situation. At some areas in scripting, the logger functionality works, but wathever I try to make new, I never get anything to log. Now I tried in the Script console the following code:  
logger = system.util.getLogger("test")  
logger.error("Hello World")

It runs without any error but there is nothing in the log on the gateway.

How can I trouble shoot this issue?  
Thanks for any hint.

---

<div class="post-metadata">

**Author:** ![diamond](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@diamond](https://forum.inductiveautomation.com/u/diamond)\
**Post date:** [June 24, 2024, 7:59pm UTC](https://forum.inductiveautomation.com/t/logger-not-logging/92299/2 "2024-06-24T19:59:45Z")

</div>

Try:

> system.perspective.print("Hello")

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [June 24, 2024, 8:03pm UTC](https://forum.inductiveautomation.com/t/logger-not-logging/92299/3 "2024-06-24T20:03:47Z")

</div>

> [@Herbert\_Augustiny](#):
>
> Script console

This is running on your designer, I don't believe it will go to the gateway when called in the script console scope.

---

<div class="post-metadata">

**Author:** ![Herbert\_Augustiny](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@Herbert\_Augustiny](https://forum.inductiveautomation.com/u/Herbert_Augustiny)\
**Post date:** [June 24, 2024, 8:09pm UTC](https://forum.inductiveautomation.com/t/logger-not-logging/92299/4 "2024-06-24T20:09:56Z")

</div>

AttributeError: 'com.inductiveautomation.ignition.designer.gui.tool' object has no attribute 'perspective'

---

<div class="post-metadata">

**Author:** ![diamond](https://avatars.discourse-cdn.com/v4/letter/d/e79b87/32.png) [@diamond](https://forum.inductiveautomation.com/u/diamond)\
**Post date:** [June 24, 2024, 8:13pm UTC](https://forum.inductiveautomation.com/t/logger-not-logging/92299/5 "2024-06-24T20:13:26Z")

</div>

Ups, didn't read that "script console" thing.

Script console is running in your computer. Is like just having a standalone Python installed in your pc. You can't pass logs to the gateway from the script console.

---

<div class="post-metadata">

**Author:** ![Herbert\_Augustiny](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@Herbert\_Augustiny](https://forum.inductiveautomation.com/u/Herbert_Augustiny)\
**Post date:** [June 24, 2024, 8:25pm UTC](https://forum.inductiveautomation.com/t/logger-not-logging/92299/6 "2024-06-24T20:25:07Z")

</div>

OK, thanks for the information, that makes sense.

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [June 24, 2024, 8:28pm UTC](https://forum.inductiveautomation.com/t/logger-not-logging/92299/7 "2024-06-24T20:28:47Z")

</div>

The scripting in the script console logs locally as @diamond said and you'll see those logs in the diagnostics of your designer.

I've also written a couple of scripts to force logging to the gateway with this called from Vision and using this instead of the standard logger:

```python
def logToGateway(message, logger='VisionClient', level='info'):
	'''
	Logs a message to the Ignition Gateway instead of the local client logs
	
	Args:
		messsage (str): Message string
		logger (str): Name of logger to log the message under
		level (str): Log Level (fatal, error, warn, info, debug, trace)
		
	'''
	system.util.sendMessage('GatewayScripts', 'LogToGateway', {'message': message, 'logger': logger, 'level': level})

```

And a Gateway Event Message script "LogToGateway" in a project named "GatewayScripts" with the following:

```python
def handleMessage(payload):
	"""
	
	Payload should include the following dictionary items:
		logger: Name of Logger for Gateway Logs
		level: Log level (fatal, error, warn, info, debug, or trace)
		message: Message to log
		
	"""

	loggerName = 'LogToGateway' if not payload['logger'] else payload['logger']
	level = 'info' if not payload['level'] else payload['level'].lower()
	
	logger = system.util.getLogger(loggerName)
	try:
		if level == 'fatal':
			logger.fatal(payload['message'])
		elif level == 'error':
			logger.error(payload['message'])
		elif level == 'warn':
			logger.warn(payload['message'])
		elif level == 'info':
			logger.info(payload['message'])
		elif level == 'debug':
			logger.debug(payload['message'])
		elif level == 'trace':
			logger.trace(payload['message'])
	except:
		pass

```

---

<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 24, 2024, 10:11pm UTC](https://forum.inductiveautomation.com/t/logger-not-logging/92299/8 "2024-06-24T22:11:13Z")

</div>

When you need to test code in gateway scope, you might find my Integration Toolkit's [system.util.runInGateway](https://www.automation-pros.com/toolkit/doc/utility.html#runingateway) decorator handy.
