如何在Junit中使`_logger.isDebugEnabled()`条件为false?

时间:2017-06-14 10:07:31

标签: java unit-testing junit

如何在Junit中使_logger.isDebugEnabled()条件为false?

private static final Logger _logger = Logger.getLogger(InstanceReleaseMachine.class);

if (_logger.isDebugEnabled())
        {
            _logger.debug("Error from Releasing Instance: " + failure);
        }

据我所知,我无法做到,如果有人这样做,请告诉我。

1 个答案:

答案 0 :(得分:1)

您可以在单元测试中以编程方式设置level = OFF:

    Logger.getRootLogger().setLevel(Level.OFF);