{"library":"logzio-python-handler","title":"Logz.io Python Handler","description":"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.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install logzio-python-handler","pip install 'logzio-python-handler[opentelemetry-logging]'"],"cli":null},"imports":["from logzio.handler import LogzioHandler","from logzio.handler import ExtraFieldsLogFilter","from logzio.flusher import LogzioFlusher"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import logging\nimport os\nfrom logzio.handler import LogzioHandler\n\n# Replace with your Logz.io token and log type\nLOGZIO_TOKEN = os.environ.get('LOGZIO_TOKEN', 'YOUR_LOGZIO_TOKEN')\nLOGZIO_TYPE = os.environ.get('LOGZIO_TYPE', 'python-application')\n\nif LOGZIO_TOKEN == 'YOUR_LOGZIO_TOKEN':\n    print(\"WARNING: Please set the LOGZIO_TOKEN environment variable or replace 'YOUR_LOGZIO_TOKEN' in the script.\")\n    print(\"Skipping Logz.io handler configuration for quickstart.\")\n    # Fallback to console logging if token is not set\n    logging.basicConfig(level=logging.INFO)\n    logger = logging.getLogger(__name__)\nelse:\n    logger = logging.getLogger(__name__)\n    logger.setLevel(logging.INFO)\n\n    try:\n        handler = LogzioHandler(\n            LOGZIO_TOKEN,\n            logzio_type=LOGZIO_TYPE\n            # url=\"https://listener.logz.io:8071\" # Default, uncomment to specify a different listener URL\n            # debug=True # Uncomment for debug output to stdout\n        )\n        logger.addHandler(handler)\n        print(f\"Logz.io handler configured for type: {LOGZIO_TYPE}\")\n    except Exception as e:\n        print(f\"Error configuring Logz.io handler: {e}\")\n        print(\"Falling back to console logging.\")\n        logging.basicConfig(level=logging.INFO)\n        logger = logging.getLogger(__name__)\n\nlogger.info(\"This is an informational message sent via Logz.io handler.\")\nlogger.warning(\"This is a warning message.\")\ntry:\n    1 / 0\nexcept ZeroDivisionError:\n    logger.exception(\"An error occurred during division. Full stack trace will be sent.\")\n\n# In a real application, the handler manages a background thread for sending logs.\n# For simple scripts, a short delay might be needed to ensure logs are sent\n# before the script exits, though graceful shutdown attempts to drain remaining logs.\nimport time\ntime.sleep(1) # Give the handler a moment to flush logs for short scripts","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"4.1.9","pypi_latest":"4.1.9","is_stale":false,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":3.1,"avg_import_s":0.58,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"opentelemetry-logging","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.53,"mem_mb":9.9,"disk_size":"27.5M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"logzio-python-handler","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.59,"mem_mb":9.9,"disk_size":"23.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"opentelemetry-logging","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.7,"import_time_s":0.38,"mem_mb":9.9,"disk_size":"28M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"logzio-python-handler","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.7,"import_time_s":0.37,"mem_mb":9.9,"disk_size":"24M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"opentelemetry-logging","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.73,"mem_mb":11,"disk_size":"30.5M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"logzio-python-handler","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.7,"mem_mb":11,"disk_size":"25.6M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"opentelemetry-logging","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.7,"import_time_s":0.6,"mem_mb":11,"disk_size":"31M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"logzio-python-handler","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.5,"import_time_s":0.6,"mem_mb":11,"disk_size":"26M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"opentelemetry-logging","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.64,"mem_mb":11.5,"disk_size":"22.1M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"logzio-python-handler","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.64,"mem_mb":11.5,"disk_size":"17.4M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"opentelemetry-logging","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.1,"import_time_s":0.64,"mem_mb":11.5,"disk_size":"23M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"logzio-python-handler","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.3,"import_time_s":0.63,"mem_mb":11.5,"disk_size":"18M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"opentelemetry-logging","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.64,"mem_mb":11.8,"disk_size":"21.9M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"logzio-python-handler","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.64,"mem_mb":11.8,"disk_size":"17.1M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"opentelemetry-logging","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3,"import_time_s":0.62,"mem_mb":11.8,"disk_size":"23M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"logzio-python-handler","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.3,"import_time_s":0.67,"mem_mb":11.8,"disk_size":"18M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"opentelemetry-logging","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.51,"mem_mb":9.6,"disk_size":"26.7M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"logzio-python-handler","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.49,"mem_mb":9.6,"disk_size":"22.3M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"opentelemetry-logging","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":4.3,"import_time_s":0.44,"mem_mb":9.6,"disk_size":"28M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"logzio-python-handler","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.1,"import_time_s":0.45,"mem_mb":9.6,"disk_size":"23M"}]}}