Loggly Python Handler
raw JSON → 1.0.1 verified Fri May 01 auth: no python
A Python logging handler that sends log messages to Loggly's cloud-based log management service. Current version 1.0.1 (last updated 2021). Release cadence is low; no recent updates. Supports both HTTP and HTTPS endpoints with optional tags and SSL verification.
pip install loggly-python-handler Common errors
error ImportError: No module named 'loggly' ↓
cause The package is installed but the import path is incorrect or missing dependencies (requests).
fix
Install dependencies: pip install requests; then import using 'from loggly.handlers import LogglyHandler'.
error TimeoutError: HTTPSConnectionPool(host='logs-01.loggly.com', port=443): Read timed out. ↓
cause Network connectivity issue or Loggly endpoint unreachable. The default timeout is 2 seconds, which might be too short.
fix
Increase timeout by subclassing LogglyHandler or switch to a different logging library that supports async timeouts.
Warnings
gotcha The handler uses synchronous HTTP(S) requests by default, which can block your application. Consider using async or queue-based logging in production. ↓
fix Use loggly.handlers.LogglyHandler with a queued handler or offload logging to a separate thread.
gotcha SSL verification fails in some environments (e.g., corporate proxies, outdated cert bundles). The handler has no easy way to disable SSL verification. ↓
fix Set the environment variable PYTHONHTTPSVERIFY=0 or patch the handler to pass verify=False; otherwise use HTTPS with proper certificates.
Imports
- LogglyHandler
from loggly.handlers import LogglyHandler
Quickstart
import logging
from loggly.handlers import LogglyHandler
token = os.environ.get('LOGGLY_TOKEN', 'your-customer-token')
handler = LogglyHandler('https://logs-01.loggly.com/inputs/' + token + '/tag/python/')
handler.setLevel(logging.INFO)
logger = logging.getLogger(__name__)
logger.addHandler(handler)
logger.info('Hello from loggly-python-handler')