Collecting Application Logs Using OTEL Python SDK
You can directly send logs of your application to SigNoz using the Python SDKs provided by OpenTelemetry. This is an example of how to set it up effectively.
📝 Note
The default logging level in Python is WARNING. To send all logs to SigNoz, change the default log level to DEBUG.
import logging
logging.basicConfig(level=logging.DEBUG)
To send logs to SigNoz Cloud, set the following environment variables before running your application:
OTEL_EXPORTER_OTLP_ENDPOINT: Set this environment variable to
https://ingest.<region>.signoz.cloud:443
- Set the
<region>
to match your SigNoz Cloud region
- Set the
OTEL_EXPORTER_OTLP_HEADERS: Set this to
signoz-access-token=<SIGNOZ_INGESTION_KEY>
, where<SIGNOZ_INGESTION_KEY>
is your ingestion key.Run Command: Use the following command to run your script:
OTEL_EXPORTER_OTLP_ENDPOINT="https://ingest.{region}.signoz.cloud:443" OTEL_EXPORTER_OTLP_HEADERS="signoz-ingestion-key=<SIGNOZ_INGESTION_KEY>" python3 example.py