Skip to content

Commit d9d5ddb

Browse files
chore(logger): disable native logging by default (#15005)
## Description Disable native logging by default as it shouldn't be logging to file by default. ## Testing <!-- Describe your testing strategy or note what tests are included --> ## Risks <!-- Note any risks associated with this change, or "None" if no risks --> ## Additional Notes <!-- Any other information that would be helpful for reviewers --> --------- Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com>
1 parent 0a50af6 commit d9d5ddb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

ddtrace/_logger.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ def _configure_ddtrace_native_logger():
131131
from .settings._config import config
132132

133133
if config._trace_writer_native:
134-
backend = get_config("_DD_NATIVE_LOGGING_BACKEND", "file", report_telemetry=True)
134+
backend = get_config("_DD_NATIVE_LOGGING_BACKEND")
135+
if not backend:
136+
return
135137
kwargs = {"output": backend}
136138
if backend == "file":
137139
kwargs["path"] = get_config("_DD_NATIVE_LOGGING_FILE_PATH", "native.log", report_telemetry=True)

tests/tracer/test_native_logger.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_logger_configure(output, path, files, max_bytes):
6868
cases = [(config, msg, LEVELS.index(msg) >= LEVELS.index(config)) for config in LEVELS for msg in LEVELS]
6969

7070

71-
@pytest.mark.parametrize("backend", ["stdout", "stderr", "file"])
71+
@pytest.mark.parametrize("backend", ["", "stdout", "stderr", "file"])
7272
@pytest.mark.parametrize("configured_level, message_level, should_log", cases)
7373
def test_logger_subprocess(
7474
backend, configured_level, message_level, should_log, tmp_path, ddtrace_run_python_code_in_subprocess
@@ -93,7 +93,11 @@ def test_logger_subprocess(
9393
out, err, status, _ = ddtrace_run_python_code_in_subprocess(code, env=env)
9494

9595
assert status == 0
96-
if backend == "stdout":
96+
if backend == "":
97+
assert out == b""
98+
assert err == b""
99+
assert not log_path.exists()
100+
elif backend == "stdout":
97101
found = message in out.decode("utf8")
98102
assert err == b""
99103
assert found == should_log

0 commit comments

Comments
 (0)