The `logzio-python-handler` library provides a Python logging handler that sends application logs to a Logz.io account. It supports bulk sending over HTTPS with SSL, handling logs asynchronously in a background thread, and offers optional OpenTelemetry trace context integration. As of version `4.1.9`, the library is actively maintained with frequent updates, primarily focusing on dependency management and robustness improvements.
pip install logzio-python-handlerVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to configure the `LogzioHandler` with Python's standard `logging` module. It uses environment variables for the Logz.io token and log type, falling back to a console logger if the token isn't set. It shows how to log informational, warning, and exception messages.
Upgrade your Python environment to version 3.5 or newer.
Implement proper shutdown hooks or a small delay in short-lived scripts if logs appear to be missing. For serverless environments, consider using `LogzioFlusher`.
Always verify your Logz.io token and listener URL are correct. Check Logz.io documentation for regional listener addresses.
Monitor log sizes for exceptions. If critical information is being truncated, consider structuring your exception logging to send key details in separate, smaller fields or custom parsing rules in Logz.io.
pip install logzio-python-handler
Verify network connectivity from your host to `listener.logz.io` on the configured port (e.g., 8071 for HTTPS). Check local firewall rules, proxy settings, or corporate network restrictions. Also, ensure the listener URL in your handler configuration is correct.
Verify that the Logz.io shipping token used in your `LogzioHandler` instantiation is correct and active in your Logz.io account. Double-check for typos or accidental truncation of the token.
Ensure that the `args` tuple for the `LogzioHandler` in your `dictConfig` lists the parameters in the precise order specified by the `logzio-python-handler` documentation: `('token', 'log_type', 'logs_drain_timeout', 'url', 'debug', 'networking_timeout', 'retries_no', 'retries_interval')`. All preceding optional parameters must be included if a later one is set.