Skip to content

A logging.Handler implementation which sends the LogRecords to the HTTP Event Collector of the Splunk server.

License

Notifications You must be signed in to change notification settings

palette-software/palette-splunk-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Palette Splunk Logger

What is Palette Splunk Logger?

It provides a logging.Handler implementation. It can be added to the any python logger like eg. StreamHandler or RotatingFileHandler. It sends the LogRecords to the HTTP Event Collector of the Splunk server.

How do I set up Palette Splunk Logger?

Prerequisites

  • 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

Package installation

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

Usage

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')

How can I test-drive Palette Splunk Logger?

Use the example code above or you may also execute some unittests by

python3 -m unittest

Is Palette Splunk Logger supported?

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.

About

A logging.Handler implementation which sends the LogRecords to the HTTP Event Collector of the Splunk server.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages