From 298e48d4d3d1186799d8d9116898aed30a8bc6d4 Mon Sep 17 00:00:00 2001 From: Wan Tsui Date: Wed, 13 Dec 2023 10:42:33 -0500 Subject: [PATCH] [APM][Python] Clarify 2.x debug tracer behavior for dd-trace-py (#20929) * clarify 2.x debug behavior * Update content/en/tracing/troubleshooting/tracer_debug_logs.md Co-authored-by: Kari Halsted <12926135+kayayarai@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: cecilia saixue watt --------- Co-authored-by: Kari Halsted <12926135+kayayarai@users.noreply.github.com> Co-authored-by: cecilia saixue watt --- .../troubleshooting/tracer_debug_logs.md | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/content/en/tracing/troubleshooting/tracer_debug_logs.md b/content/en/tracing/troubleshooting/tracer_debug_logs.md index 94bfec850e7d9..8006a0301c09d 100644 --- a/content/en/tracing/troubleshooting/tracer_debug_logs.md +++ b/content/en/tracing/troubleshooting/tracer_debug_logs.md @@ -32,7 +32,28 @@ To enable debug mode for the Datadog Java Tracer, set the flag `-Ddd.trace.debug The steps for enabling debug mode in the Datadog Python Tracer depends on the version of the tracer your application is using. Choose the scenario that applies: -### Scenario 1: ddtrace version 1.3.2 or higher +### Scenario 1: ddtrace version 2.x and higher + +1. To enable debug mode: `DD_TRACE_DEBUG=true` + +2. To route debug logs to a log file, set `DD_TRACE_LOG_FILE` to the filename of that log file, relative to the current working directory. For example, `DD_TRACE_LOG_FILE=ddtrace_logs.log`. + By default, the file size is 15728640 bytes (about 15MB), and one backup log file is created. To increase the default log file size, specify the size in bytes with the `DD_TRACE_LOG_FILE_SIZE_BYTES` setting. + +**Note:** If the application uses the root logger and changes log level to `DEBUG`, debug tracer logs are enabled. If you want to override this behavior, override the `ddtrace` logger as follows: + +``` +import logging + +# root logger configuration +root_logger = logging.getLogger() +root_logger.setLevel(logging.DEBUG) + +# override the ddtrace configuration to WARNING log level +logging.getLogger("ddtrace").setLevel(logging.WARNING) +``` + + +### Scenario 2: ddtrace version 1.3.2 to <2.x 1. To enable debug mode: `DD_TRACE_DEBUG=true` @@ -42,19 +63,19 @@ The steps for enabling debug mode in the Datadog Python Tracer depends on the ve 3. To route logs to the console, for **Python 2** applications, configure `logging.basicConfig()` or similar. Logs are automatically sent to the console for **Python 3** applications. -### Scenario 2: ddtrace version 1.0.x to 1.2.x +### Scenario 3: ddtrace version 1.0.x to 1.2.x 1. To enable debug mode: `DD_TRACE_DEBUG=true` 2. To route logs to the console, for **Python 2 or Python 3** applications, configure `logging.basicConfig()` or use `DD_CALL_BASIC_CONFIG=true`. -### Scenario 3: ddtrace version 0.x +### Scenario 4: ddtrace version 0.x 1. To enable debug mode: `DD_TRACE_DEBUG=true` 2. To route logs to the console, for **Python 2 or Python 3** applications, configure `logging.basicConfig()` or use `DD_CALL_BASIC_CONFIG=true`. -### Scenario 4: Configuring debug logging in the application code with the standard logging library +### Scenario 5: Configuring debug logging in the application code with the standard logging library For any version of ddtrace, rather than setting the `DD_TRACE_DEBUG` tracer environment variable, you can enable debug logging in the application code by using the `logging` standard library directly: