Skip to content

Conversation

@asolntsev
Copy link
Contributor

@asolntsev asolntsev commented Nov 12, 2025

User description

People do debug their tests, and they don't want to see Selenium own debug logs. Especially DevTools/BiDi logs which are huge (encoded Base64 data, incl. screenshots etc).

🔗 Related Issues

When i debug my UI tests, I see unneeded debugging info in my logs:

Nov 12, 2025 2:07:53 PM org.openqa.selenium.devtools.Connection send
INFO: -> {
  "method": "Page.captureScreenshot",
  "params": {
    "optimizeForSpeed": true
  },
  "id": 5,
  "sessionId": "389935989A6DCCBF62C2CD8102FCD7FD"
}
Nov 12, 2025 2:07:53 PM org.openqa.selenium.devtools.Connection handle
INFO: <- {"id":5,"result":{"data":"... HUGE BASE64-encoded binary data ...=="},"sessionId":"389935989A6DCCBF62C2CD8102FCD7FD"}

💥 What does this PR do?

Change method Debug.isDebugging(), so that it doesn't depend on "RUN" or "DEBUG" JVM mode.
Now the debug logs can only be implicitly turned on.

💡 Additional Considerations

With a great pleasure, I would remove Debug.java at all.
These logs should be always written with TRACE level.
When someone needs these logs, he should just set TRACE logging level for package org.openqa.selenium.bidi or org.openqa.selenium.devtools.

🔄 Types of changes

  • Bug fix (backwards compatible)

PR Type

Bug fix


Description

  • Remove JVM debug mode detection from Debug.isDebugging()

  • Prevent DevTools/BiDi debug logs appearing at INFO level

  • Only allow explicit debug enablement via system properties

  • Users can enable TRACE logging for specific packages instead


Diagram Walkthrough

flowchart LR
  A["Debug.isDebugging()"] -->|Previously checked| B["JVM -agentlib:jdwp flag"]
  A -->|Previously checked| C["System properties"]
  B -->|Removed| D["Unwanted INFO logs"]
  C -->|Kept| E["Explicit debug control"]
  E -->|Recommended| F["Use TRACE logging level"]
Loading

File Walkthrough

Relevant files
Bug fix
Debug.java
Remove automatic JVM debug mode detection                               

java/src/org/openqa/selenium/internal/Debug.java

  • Removed ManagementFactory import and JVM debug flag detection
  • Removed check for -agentlib:jdwp in runtime arguments
  • Kept only explicit system property checks (selenium.debug and
    selenium.webdriver.verbose)
  • Simplified IS_DEBUG initialization logic
+1/-5     

@selenium-ci selenium-ci added the C-java Java Bindings label Nov 12, 2025
@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Nov 12, 2025

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
  • Create ticket/issue
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
Audit impact unclear: The change alters when debug logging is enabled by removing JVM debug detection, which may
reduce visibility of certain actions, but the diff alone does not show any critical action
logging being added or removed.

Referred Code
static {
  boolean simpleProperty = Boolean.getBoolean("selenium.debug");
  boolean longerProperty = Boolean.getBoolean("selenium.webdriver.verbose");

  IS_DEBUG = simpleProperty || longerProperty;

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@asolntsev asolntsev requested a review from shs96c November 12, 2025 12:14
@qodo-merge-pro
Copy link
Contributor

qodo-merge-pro bot commented Nov 12, 2025

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Log debug information at FINE level

To align with the PR's goal of avoiding INFO level for debug logs, modify
getDebugLogLevel() to always return Level.FINE instead of conditionally
returning Level.INFO.

java/src/org/openqa/selenium/internal/Debug.java [42-44]

 public static Level getDebugLogLevel() {
-  return isDebugging() ? Level.INFO : Level.FINE;
+  return Level.FINE;
 }

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 8

__

Why: The suggestion correctly identifies that the PR does not fully achieve its stated goal, as debug logs can still be at Level.INFO, and proposes a change that fully aligns the code with the PR's intent.

Medium
  • Update

@cgoldberg cgoldberg changed the title Avoid logging debug logs with INFO level (either in RUN or DEBUG mode) [java] Avoid logging debug logs with INFO level (either in RUN or DEBUG mode) Nov 12, 2025
... either in RUN or DEBUG mode.
People do debug their tests, and they don't want to see Selenium own debug logs. Especially DevTools/BiDi logs which are huge (encoded Base64 data, incl. screenshots etc).
@asolntsev asolntsev force-pushed the fix/devtools-log-level branch from c1df8d4 to eb53b7e Compare November 14, 2025 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants