Logging¶
Enabling/Disabling/Changing Log Level at Runtime¶
Sometime you want to be able to enable console logging or change a logging level directly in a script without the need for an idmtools.ini file. The following example shows how to do that.
from logging import getLogger
from idmtools.core.logging import setup_logging, IdmToolsLoggingConfig
# At any point in running you can import the setup logging to reset logging
# In this example, we enable the console logger at run time
logger = getLogger()
logger.debug("This will not be visible at the command line")
setup_logging(IdmToolsLoggingConfig(console=True, level='DEBUG', force=True))
logger.debug("You should be able to see this at the command line")
See Logging overview for details on configuring logging through the idmtools.ini.