Use custom logging
The Splunk Machine Learning Toolkit ships with utilities to make logging easier to manage.
The Splunk Machine Learning Toolkit relies on a different Python interpreter than the interpreter shipped with Splunk Enterprise.
To begin, import a logger. For more detailed logging, you can use a logger with a custom name as in the following example:
from cexc import get_logger logger = get_logger('MyCustomLogging') logger.warn('warning!') logger.error('error!') logger.debug('info!')
The logger messages are logged to $SPLUNK_HOME/var/log/mlspl.log
.
Along with the name provided in get_logger
, the function ,in this case the __init__ method
), is also recorded:
1491862833.627798 2017-04-10 15:20:33,627 WARNING [mlspl.MyCustomLogging] [__init__] warning! 1491862833.627949 2017-04-10 15:20:33,627 ERROR [mlspl.MyCustomLogging] [__init__] error! 1491862833.628024 2017-04-10 15:20:33,628 DEBUG [mlspl.MyCustomLogging] [__init__] info!
When all else fails, the best place to look is search.log
. If you get stuck, ask questions and get answers through community support at Splunk Answers.
Create user facing messages | Adding Python 3 libraries |
This documentation applies to the following versions of Splunk® Machine Learning Toolkit: 4.4.0, 4.4.1, 4.4.2, 4.5.0, 5.0.0
Feedback submitted, thanks!