It provides a logging.Handler
implementation. It can be added to the any python logger like eg. StreamHandler
or RotatingFileHandler
.
It sends the LogRecord
s to the HTTP Event Collector of the Splunk server.
- Palette Splunk Logger is compatible with Python 3.5
- The hostname and the HTTP Event Collector URL of the Splunk Server
- An Access Token to the HTTP Event Collector
Either copy the splunkloghandler.py
to your project or you may use the setup.py
to create a package.
python setup.py sdist
pip install dist/palette-splunk-logger-1.0.0.tar.gz
You may instantiate the AsyncSplunkLogHandler
class and add the handler to the logger.
import splunkloghandler
ACCESS_TOKEN = 'YOUR TOKEN'
API_DOMAIN = 'YOUR SPLUNK SERVER HOSTNAME'
API_URL = '/services/collector/event'
logger = logging.getLogger('simple_example')
logger.setLevel(logging.DEBUG)
sh = splunkloghandler.AsyncSplunkLogHandler(host=API_DOMAIN,
url=API_URL,
token=ACCESS_TOKEN,
secure=True)
sh.setLevel(logging.DEBUG)
logger.addHandler(sh)
logger.debug('debug message')
logger.info('info message')
logger.warning('warn message')
logger.error('error message')
logger.critical('critical message')
Use the example code above or you may also execute some unittests by
python3 -m unittest
Palette Splunk Logger is licensed under the MIT License. For professional support please contact [email protected].
Any bugs discovered should be filed in the Palette Splunk Logger Git issue tracker or contribution is more than welcome.