2016-11-21T23:42:35
Logging with Python
import logging
logging_config = {
'filename': '/var/log/app_log',
'format': '%(asctime)s [%(levelname)s] %(message)s',
'level': logging.INFO
}
logging.basicConfig(**logging_config)
logging.info('Our logged message.')
This will output the following to /var/log/app_log:
2016-11-21 23:50:53,677 [INFO] Our logged message.
Source: https://docs.python.org/2/howto/logging.html#logging-basic-tutorial