Skip to content

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

@4e6

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));
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    ❓New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions