Skip to content

System.Logger.isLoggable returns true for any level #14948

Description

@4e6

Issue

In the current setup java.lang.System.Logger.isLoggable always returns true.

private static final System.Logger LOG = System.getLogger(Ydoc.class.getName());

var isDebug = LOG.isLoggable(System.Logger.Level.DEBUG);

Currently isDebug == true always

Info

LogbackSetup sets loglevel to TRACE. Math.min(TRACE, anything) always returns TRACE because it is the lowest level.

// Root's log level is set to the minimal required log level.
// Log level is controlled by `ThresholdFilter` instead, allowing is to specify different
// log levels for different outputs.
var minLevelInt = Math.min(Level.TRACE.toInt(), level.toInt());
var minLevel =
ch.qos.logback.classic.Level.convertAnSLF4JLevel(Level.intToLevel(minLevelInt));
logger.setLevel(minLevel);

Then SystemViaSlf4jLogger checks the Logback logger's effective level (TRACE), resulting in true for any level

public boolean isLoggable(Level level) {
return delegate.isEnabledForLevel(at(level));
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions