> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeycomb.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Example: Send OpenTelemetry Logs with the OpenTelemetry Python SDK

> Configure the OpenTelemetry Python SDK logger provider to send structured logs from your Python application to Honeycomb or a Collector.

<Note>
  Logs support in the OpenTelemetry Python SDK is currently experimental and subject to change.
  To check the status for each language, refer to the [OpenTelemetry status page](https://opentelemetry.io/status/).
</Note>

This example shows how to configure the OpenTelemetry Python SDK's logger provider to send logs from a Python application to Honeycomb or an OpenTelemetry Collector.

<Steps titleSize="h2">
  <Step title="Acquire Dependencies">
    Install the OpenTelemetry API, SDK, and OTLP exporter packages:

    ```shell theme={}
    pip install opentelemetry-api
    pip install opentelemetry-sdk
    pip install opentelemetry-exporter-otlp
    ```
  </Step>

  <Step title="Configure the Logger Provider">
    During application setup, create and configure the logger provider:

    ```python theme={}
    import logging

    from opentelemetry._logs import set_logger_provider
    from opentelemetry.exporter.otlp.proto.grpc._log_exporter import OTLPLogExporter
    from opentelemetry.sdk._logs import LoggerProvider, LoggingHandler
    from opentelemetry.sdk._logs.export import BatchLogRecordProcessor
    from opentelemetry.sdk.resources import Resource

    # Create and set the logger provider
    logger_provider = LoggerProvider()
    set_logger_provider(logger_provider)

    # Create the OTLP log exporter that sends logs to configured destination
    exporter = OTLPLogExporter()
    logger_provider.add_log_record_processor(BatchLogRecordProcessor(exporter))

    # Attach the OTLP handler to the root logger
    handler = LoggingHandler(logger_provider=logger_provider)
    logging.getLogger().addHandler(handler)

    # Use logging directly anywhere in your app
    logging.warning("Something interesting happened")

    # Shut down the logger before exiting to export all pending logs
    logger_provider.shutdown()
    ```
  </Step>

  <Step title="Run Your Application">
    Set environment variables to configure the exporter and define your service name, then run your application.

    To send logs directly to Honeycomb:

    ```shell theme={}
    OTEL_SERVICE_NAME="my-service" \
      OTEL_EXPORTER_OTLP_ENDPOINT="https://api.honeycomb.io" \
      OTEL_EXPORTER_OTLP_HEADERS="x-honeycomb-team=<your-api-key>" \
      python app.py
    ```

    To send logs to an OpenTelemetry Collector instead:

    ```shell theme={}
    OTEL_SERVICE_NAME="my-service" \
      OTEL_EXPORTER_OTLP_ENDPOINT="my-collector:4317" \
      OTEL_EXPORTER_OTLP_INSECURE=true \
      python app.py
    ```
  </Step>
</Steps>
