The chat responses are generated using Generative AI technology for intuitive search and may not be entirely accurate. They are not intended as professional advice. For full details, including our use rights, privacy practices and potential export control restrictions, please refer to our Generative AI Service Terms of Use and Generative AI Service Privacy Information. As this is a test version, please let us know if something irritating comes up. Like you get recommended a chocolate fudge ice cream instead of an energy managing application. If that occurs, please use the feedback button in our contact form!
Skip to content
Insights Hub and Industrial IoT

Insights Hub drives smart manufacturing through the industrial Internet of Things. Gain actionable insights with asset and operational data and improve your processes.

Industrial IoT SDK for Python Logging¶

Introduction¶

Logging of the Industrial IoT SDK for Python is implemented using the logging module by Python, which can be configured to different log levels and a custom logging format.

Usage¶

The default log level is INFO. Configure the logging using the log_config module in mindsphere_core. It contains a method called setup_logging which allows users to configure log levels and log formats.

Setting the Log Level¶

# Import log_config from mindsphere_core
import log_config from mindsphere_core

# Setting Log Level to DEBUG
logger = log_config.setup_logging(level=logging.DEBUG)

The following log level are supported:

  • CRITICAL
  • ERROR
  • WARNING
  • INFO
  • DEBUG
  • NOTSET

Setting Log Format¶

Configure the log format to log only the message or the message with time:

# Import log_config from mindsphere_core
import log_config from mindsphere_core

# Display Logs in the format : Log Message 
logger = log_config.setup_logging(format="%(message)s")

# Display Logs in the format : Time - Classname - Log Level - Log Message 
logger = log_config.setup_logging(format="%(asctime)s - %(name)20s - %(levelname)6s - %(message)s")

# Display Logs in the format : name: <Classname>, level - <Log Level>, time: <time>, message: <Log Message> 
logger = log_config.setup_logging(format="name: %(name)s, level: %(levelname)s, time: %(asctime)s, message: %(message)s")

Disable Logging¶

Set the log level to NOTSET to disable logging:

# Import log_config from mindsphere_core
import log_config from mindsphere_core

# To disable logging, set the Log Level to NOTSET
logger = log_config.setup_logging(level=logging.NOTSET)