Skip to main content

Log handler to send log via exchange.

Project description

exchange_log_handler

Log handler to send log via exchange

Dependencies

This library used ecederstrand/exchangelib to send exchange mail.

How to install:

pip install exchange_log_handler

Usage:

if __name__ == '__main__':
    import logging
    import logging.config
    logging.config.dictConfig({
        'version': 1,
        'disable_existing_loggers': False,
        'handlers': {
            'console': {
                'level': 'INFO',
                'class': 'logging.StreamHandler',
                'stream': 'ext://sys.stdout',
            },
            'email': {
                'level': 'ERROR',
                'class': 'exchange_log_handler.ExchangeHandler',
                'credentials': ('email_address', 'email_password'),
                'subject': lambda r: '{0}-{1}'.format(r.levelname, r.name),
                'toaddrs': 'recipient_email_address',
            },
        },
        'loggers': {
            '': {
                'handlers': [ 'console', 'email' ],
                'level': 'DEBUG',
                'propagate': True,
            },
        },
    })

    logger = logging.getLogger(__name__)
    try:
        raise ValueError('This is a test exception.')
    except Exception as e:
        logger.exception(e)

Project details


Release history Release notifications

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for exchange-log-handler, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size exchange_log_handler-0.1.0-py3-none-any.whl (7.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size exchange_log_handler-0.1.0.tar.gz (2.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page