Splunk® Machine Learning Toolkit

ML-SPL API Guide

Use custom logging

The Splunk Machine Learning Toolkit (MLTK) ships with utilities to make logging easy to manage.

MLTK relies on a different Python interpreter than the interpreter that ships with Splunk Enterprise.

To begin, import a logger. For more detailed logging, you can use a logger with a custom name as shown in the following example:

from cexc import get_logger

logger = get_logger('MyCustomLogging')
logger.warn('warning!')
logger.error('error!')
logger.debug('info!')

Logger messages are logged to $SPLUNK_HOME/var/log/mlspl.log.

Along with the name provided in get_logger, the function 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!

If you cannot find messages using the logger, you can also look in the search.log.

Last modified on 31 January, 2024
Create user facing messages   Adding Python 3 libraries

This documentation applies to the following versions of Splunk® Machine Learning Toolkit: 5.1.0, 5.2.0, 5.2.1, 5.2.2, 5.3.0, 5.3.1, 5.3.3, 5.4.0, 5.4.1, 5.4.2, 5.5.0


Was this topic useful?







You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters