代替 log4j 中 Priority.DEBUG 的方法

Instead method for Priority.DEBUG in log4j

我想用slf4j将log4j 1.2版本升级到log4j 2.7版本。在我的代码中有。

if (logger.isEnabledFor(Priority.DEBUG)){
            logger.debug("Exit checkAccess()");
        }

这个函数但是 Priority.DEBUG 方法被弃用了所以我使用 Level.DEBUG 并导入 "org.slf4j.event.Level" 但它仍然显示以下错误 "The method isEnabledFor(Level) is undefined for the type Logger"

我找到了这个问题的解决方案..

if (logger.isDebugEnabled(){
        logger.debug("Exit checkAccess()");
    }

这是 log4j 2.7 中实现的方法