Skip to main content

otel-log

OpenTelemetry-compliant structured logging for Python. Produces JSON logs conforming to the OTel Log Data Model and optionally configures distributed tracing from a single call.

Installation

# Logging only (lightweight — only opentelemetry-api required)
pip install otel-log

# Logging + tracing
pip install otel-log[tracing]

Quick Start

import otel_log

result = otel_log.setup("my-service", version="1.0.0")

import logging
logging.info("Hello world")
# => {"Timestamp":"...","SeverityText":"INFO","SeverityNumber":9,"Body":"Hello world","Resource":{"service.name":"my-service","service.version":"1.0.0"}}

result.shutdown()

With Tracing

import otel_log

result = otel_log.setup("my-service", endpoint="localhost:4317")

with result.tracer.start_as_current_span("my-operation"):
    logging.info("Inside a span")
    # TraceId, SpanId, TraceFlags auto-injected into the JSON output

Advanced Usage

For auto-instrumentors, custom exporters, or fine-grained configuration:

from otel_log import OTelInitializer, ResourceConfig, InstrumentationConfig

result = OTelInitializer.initialize(
    resource_config=ResourceConfig(
        service_name="my-service",
        service_version="1.0.0",
        deployment_environment="production",
        custom_attributes={"cloud.region": "us-east-1"},
    ),
    instrumentation_config=InstrumentationConfig(
        endpoint="localhost:4317",
        protocol="grpc",
    ),
)

Environment Variables

Variable Required Description
OTEL_SERVICE_NAME Yes Service name (overrides config)
OTEL_EXPORTER_OTLP_ENDPOINT No OTLP trace exporter endpoint. If unset, tracing is disabled (no-op).
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT No OTLP log exporter endpoint. If unset, logs go to console only.
OTEL_RESOURCE_ATTRIBUTES No Comma-separated key=value resource attributes

Output Format

All logs conform to the shared JSON schema:

{
  "Timestamp": "2026-03-22T12:00:00.000000Z",
  "SeverityText": "INFO",
  "SeverityNumber": 9,
  "Body": "User logged in",
  "Resource": {"service.name": "my-service"},
  "TraceId": "0af7651916cd43dd8448eb211c80319c",
  "SpanId": "b7ad6b7169203331",
  "TraceFlags": "01"
}

License

Proprietary. All rights reserved.

Metadata

Release files for otel-log 0.6.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for otel-log 0.6.6
File Size Uploaded Provenance Actions
otel_log-0.6.6.tar.gz 32.6 kB Without provenance Details for otel_log-0.6.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for otel-log 0.6.6
File Interpreter ABI Platform Actions
otel_log-0.6.6-py3-none-any.whl Python 3 none any Details for otel_log-0.6.6-py3-none-any.whl

Total release size: 66.4 kB

Release files / otel_log-0.6.6.tar.gz

Download URL otel_log-0.6.6.tar.gz
Size 32.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ccb6b9882e7429028c79fd8b9194d26282094772462e5825854199b724b7c255
BLAKE2b-256 checksum
How to use checksums
e08fffb335f4350f354acb0c57b57e21ca6b9d304c2ba18f0b326f722e82151c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / otel_log-0.6.6-py3-none-any.whl

Download URL otel_log-0.6.6-py3-none-any.whl
Size 33.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
33bbff10489a9ec3c7a2114494c8316e0215dfea13a388e49e8bb275bf172d62
BLAKE2b-256 checksum
How to use checksums
451e538c2d9e6411d4da3c5571b3c3e0e43d69a98ad95941627512ef0d846204
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for otel-log 0.6.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page