Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🚀 Feature]: Make Java Logging Consistent #12892

Closed
titusfortner opened this issue Oct 6, 2023 · 2 comments
Closed

[🚀 Feature]: Make Java Logging Consistent #12892

titusfortner opened this issue Oct 6, 2023 · 2 comments
Labels
A-needs decision C-java I-stale Applied to issues that become stale, and eventually closed.
Milestone

Comments

@titusfortner
Copy link
Member

Feature and motivation

Selenium library is currently taking an interesting approach to logging.

Many places in the code use getDebugLogLevel() to determine the level that something should be logged at.

That code is checking to see whether either of two property values have been set or the code is in Debug mode (e.g., IntelliJ debugger), and if it is, it logs things at the INFO level instead of the FINE level.

The nice thing about this approach is that we can tell people to do:

System.setProperty("selenium.debug", "true")

instead of having them learn how to use the root logger, etc as described here: https://www.selenium.dev/documentation/webdriver/troubleshooting/logging/

The other nice thing is that we don't have to worry about what other logging handlers they might be using, we don't have to override anything, we can just make our code log at a default visible level.

The less nice thing about this approach is that it isn't obvious why it's happening or how to change it.

Also, the toggle is based on a static block on the class, so changing the System property during the test will not change the behavior, which is limiting.

More importantly, right now some things are logged this way and some things aren't and I think we need to be consistent one way or another.

Options:

  1. Deprecate selenium.webdriver.verbose and selenium.debug and remove the whole class
  2. Move everything that is "general debug" information to use getDebugLogLevel() (keep the things I changed to log at FINER level at the FINER level — [java] reduce log noise at FINE level #12866)
  3. Remove the conditional to toggle this on automatically in Debug mode
  4. Have the system property change the level the user is logging things rather than changing the level the line is getting logged at (this could break things for users if they have other implementations)
  5. Let the the user change the debug mode on the fly via System property

The first feels too drastic, but I'm ok with requesting people use an alternate solution if we agree that's better.

Changing the user's logging level for them could be, depending:

Logger rootLogger = Logger.getLogger("");
Arrays.stream(logger.getHandlers()).forEach(handler -> {
    handler.setLevel(Level.FINE);
});

Usage example

n/a

@titusfortner titusfortner changed the title [🚀 Feature]: Make Java Logging Conssitent [🚀 Feature]: Make Java Logging Consistent Oct 7, 2023
@titusfortner titusfortner modified the milestone: 4.17 Dec 31, 2023
@titusfortner titusfortner added this to the Selenium 5.0 milestone May 20, 2024
Copy link

This issue is stale because it has been open 280 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the I-stale Applied to issues that become stale, and eventually closed. label Jan 15, 2025
Copy link

This issue was closed because it has been stalled for 14 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-needs decision C-java I-stale Applied to issues that become stale, and eventually closed.
Projects
None yet
Development

No branches or pull requests

1 participant