Skip to content

Commit 5858031

Browse files
Add EDOT SDK debug logging guide (elastic#2722)
This PR adds a new troubleshooting topic titled "Enable debug logging for EDOT SDKs".
1 parent c2bc78e commit 5858031

File tree

2 files changed

+180
-0
lines changed

2 files changed

+180
-0
lines changed
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
---
2+
navigation_title: Enable debug logging for SDKs
3+
description: Learn how to enable debug logging for EDOT SDKs to troubleshoot application-level instrumentation issues.
4+
applies_to:
5+
stack:
6+
serverless:
7+
observability:
8+
product:
9+
edot_sdk: ga
10+
products:
11+
- id: cloud-serverless
12+
- id: observability
13+
- id: edot-sdk
14+
---
15+
16+
# Enable debug logging for EDOT SDKs
17+
18+
You can enable debug logging for Elastic Distributions of OpenTelemetry (EDOT) SDKs to troubleshoot application-level issues.
19+
20+
Enabling debug logging can help surface common problems such as:
21+
22+
* Auto-instrumentation not attaching or being disabled
23+
* Authentication or endpoint misconfigurations
24+
* Unsupported framework or language version
25+
* Sampling rate being set too low (resulting in missing spans)
26+
27+
## General SDK troubleshooting tips
28+
29+
Check your application logs for SDK-specific output and errors. If no logs appear at all, verify that:
30+
31+
* The SDK or agent is correctly installed and loaded
32+
* The application runtime includes the correct path or classpath
33+
* The environment variables are visible to the application process
34+
* The logs are being written to the correct location
35+
36+
:::{{warning}}
37+
Debug logs can be verbose, potentially impacting performance and containing sensitive information such as system paths, variable names, or internal data structures. They shouldn't be enabled in production environments.
38+
:::
39+
40+
41+
## Java
42+
43+
You can enable debug logging using environment variables.
44+
45+
For general EDOT Java agent debugging, try:
46+
47+
```bash
48+
export ELASTIC_OTEL_JAVAAGENT_LOG_LEVEL=debug
49+
java -jar your-app.jar
50+
```
51+
The output is captured span information from the agent itself, in a JSON format.
52+
53+
If you need to see and inspect the specific trace data your application is generating, use:
54+
55+
56+
```bash
57+
export OTEL_TRACES_EXPORTER=otlp,logging-otlp
58+
java -jar your-app.jar
59+
```
60+
61+
The output are the application’s traces in a JSON format.
62+
63+
By default, logs are written to `stderr`.
64+
65+
66+
## Python
67+
68+
To enable debug logging, set the `OTEL_PYTHON_LOG_LEVEL` variable to `debug`:
69+
70+
```bash
71+
export OTEL_PYTHON_LOG_LEVEL=debug
72+
```
73+
74+
Run your application as usual, for example:
75+
76+
```bash
77+
python your_application.py
78+
```
79+
80+
81+
## .NET
82+
83+
To enable debug logging for the EDOT .NET agent, set:
84+
85+
::::{tab-set}
86+
87+
:::{tab-item} macOS
88+
89+
```bash
90+
export OTEL_LOG_LEVEL=debug
91+
```
92+
:::
93+
94+
:::{tab-item} Windows
95+
96+
```powershell
97+
$env:OTEL_LOG_LEVEL="debug"
98+
```
99+
:::
100+
::::
101+
102+
103+
## Node.js
104+
105+
Set this environment variable before starting your app:
106+
107+
::::{tab-set}
108+
109+
:::{tab-item} macOS
110+
111+
```bash
112+
export OTEL_LOG_LEVEL=debug
113+
node --import @elastic/opentelemetry-node your-app.js
114+
```
115+
:::
116+
117+
:::{tab-item} Windows
118+
119+
```powershell
120+
$env:OTEL_LOG_LEVEL="debug"
121+
node --import @elastic/opentelemetry-node your-app.js
122+
```
123+
:::
124+
::::
125+
126+
This produces debug-level logs from the SDK itself.
127+
128+
If you also want to inspect the actual telemetry your app is generating, configure exporters to log traces, metrics, or logs to the console. For example:
129+
130+
```sh
131+
export OTEL_TRACES_EXPORTER=otlp, console
132+
export OTEL_METRICS_EXPORTER=otlp, console
133+
node --import @elastic/opentelemetry-node your-app.js
134+
```
135+
136+
## PHP
137+
138+
While the EDOT PHP agent supports the standard `OTEL_LOG_LEVEL` variable, you must also configure at least one of the Elastic-specific sink options to direct logs to a destination:
139+
140+
* `ELASTIC_OTEL_LOG_LEVEL_FILE`
141+
* `ELASTIC_OTEL_LOG_LEVEL_STDERR`
142+
* `ELASTIC_OTEL_LOG_LEVEL_SYSLOG`
143+
144+
Refer to [Logging configuration](opentelemetry://reference/edot-sdks/php/configuration.md#logging-configuration) for more details.
145+
146+
For deeper troubleshooting, you can also enable diagnostic data collection. For example:
147+
148+
```bash
149+
export ELASTIC_OTEL_DEBUG_DIAGNOSTIC_FILE=/tmp/php_diag_%p_%t.txt php test.php
150+
```
151+
152+
Ensure the file path is writable by the PHP process. If multiple PHP processes are running, use directives in the diagnostic file name to generate unique files and prevent overwriting. You can use:
153+
154+
* `%p` to insert the process ID
155+
156+
* `%t` to insert the UNIX timestamp
157+
158+
After setting the variable, restart the PHP process you're collecting diagnostics for, then send an HTTP request or run a script (for PHP-CLI).
159+
160+
The collected information includes:
161+
162+
* Process ID and parent process ID
163+
164+
* User ID of the worker process
165+
166+
* Loaded PHP extensions
167+
168+
* Output from the `phpinfo()` function
169+
170+
* Memory usage and maps `(/proc/{{id}}/maps` and `/proc/{{id}}/smaps_rollup)`
171+
172+
* Process status `(/proc/{{id}}/status)`
173+
174+
Disable diagnostic collection when you're done by unsetting the variable or restoring the previous configuration.
175+
176+
177+
## Resources
178+
179+
To learn how to enable debug logging for the EDOT Collector, refer to [Enable debug logging for EDOT Collector](../edot-collector/enable-debug-logging.md).

troubleshoot/ingest/opentelemetry/toc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ toc:
1919
- file: edot-sdks/nodejs/index.md
2020
- file: edot-sdks/php/index.md
2121
- file: edot-sdks/python/index.md
22+
- file: edot-sdks/enable-debug-logging.md
2223
- file: no-data-in-kibana.md
2324
- file: contact-support.md

0 commit comments

Comments
 (0)