Search

User Manual

GETTING STARTED


MODULES AND PLATFORM


APPENDIX


TUTORIALS & HELPFUL TRICKS


STRATEGIC PARTNER LINKS

Sepasoft - MES Modules
Cirrus Link - MQTT Modules

RESOURCES

Inductive University
Ignition Demo Project
Knowledge Base Articles
Forum
IA Support
SDK Documentation
SDK Examples

ALL USER MANUAL VERSIONS

Ignition 8.1
Ignition 7.9
Ignition 7.8

Deprecated Pages

Employees

Sign In

Skip to end of metadata
Go to start of metadata

This function is used in Python Scripting.

Description
Returns a Logger object that can be used to log messages to the console. Each Logger has a name, which is typically structured hierarchically using periods, indicating where in the project the Logger is used. You can use any naming scheme you like, however a well-planned naming scheme makes finding  log entries and setting log levels much easier. Loggers can be shared between scripts simply by giving them the same name. Six levels of logging are available:
  • Fatal - A severe error that will cause termination of the script.
  • Error - A runtime error or other unexpected condition.
  • Warn - An undesired condition, but one that does not interfere with execution.
  • Info - An event that should be noted on the console, but is not an error.
  • Debug - Detailed information useful in debugging.
  • Trace - Highly detailed information.

To view log messages from Gateway scripts, in the Gateway go to Status > Diagnostics > Logs. To view log messages from Client scripts, including scripts in components, in the Client go to Help > Diagnostics > Log Viewer, or in the Designer go to Tools > Console. The default logging level is info, meaning that all messages with level info or higher are logged, and messages with a level of debug or trace are discarded.

To change the logging level for a Logger in a Gateway script, go to Status > Diagnostics > Log. Click the Settings  icon. The new logging level will remain until it is changed or the Gateway is restarted.

To change the logging level in a Client script, go to Help > Diagnostics > Logging Levels. Logging levels can not be changed in the Designer. The following methods are available to a Logger:

  • Logger.fatal(String) - Logs a message with level fatal.
  • Logger.fatalf(String, Args...) - Logs a formatted message with level fatal, using Java's Formatter syntax.
  • Logger.error(String) - Logs a message with level error.
  • Logger.errorf(String, Args...) - Logs a formatted message with level error, using Java's Formatter syntax.
  • Logger.warn(String) - Logs a message with level warn.
  • Logger.warnf(String, Args...) - Logs a formatted message with level warn, using Java's Formatter syntax.
  • Logger.info(String) - Logs a message with level info.
  • Logger.infof(String, Args...) - Logs a formatted message with level info, using Java's Formatter syntax.
  • Logger.debug(String) - Logs a message with level debug.
  • Logger.debugf(String, Args...) - Logs a formatted message with level debug, using Java's Formatter syntax.
  • Logger.trace(String) - Logs a message with level trace.
  • Logger.tracef(String, Args...) - Logs a formatted message with level trace, using Java's Formatter syntax.
  • Logger.isTraceEnabled() - Returns True if the current log level is at least trace.
  • Logger.isDebugEnabled() - Returns True if the current log level is at least debug.
  • Logger.isInfoEnabled() - Returns True if the current log level is at least info.
Client Permission Restrictions

This scripting function has no Client Permission restrictions.

Syntax

system.util.getLogger(name)

  • Parameters

String name - The name of a logger to create.

  • Returns

LoggerEx - A new LoggerEx object used to log informational and error messages. 

  • Scope

Gateway, Vision Client, Perspective Session

Code Examples
Code Snippet
# This code would log a message with level info
logger = system.util.getLogger("myLogger")
logger.info("Hello, world.")
Code Snippet - Python String Formatting syntax
# This code would log a formatted message with level info.
who = 'Bob Jones'
num = 5
logger = system.util.getLogger("myLogger")
logger.info("Machine started by %s, employee ID %d"% (who, num))
Code Snippet - Java's Formatter syntax
# This code would log a formatted message with level info. Similar to the "Python String Formatting syntax" example above, but using Java's Formatter syntax
# Note the 'f' at the end of the method name.
who = 'Bob Jones'
num = 5
logger = system.util.getLogger("myLogger")
logger.info("Machine started by %s, employee ID %d", who, num)
Code Snippet
# This code would check if the debug level is enabled for this logger before 
# executing the remaining code. Although not needed for a simple log entry like 
# in this example, it can eliminate expensive function calls in a more complex 
# log entry.
logger = system.util.getLogger("myLogger")
if logger.isDebugEnabled():
	logger.debug("Hello, world!")
Keywords

system util getLogger, util.getLogger

  • No labels