Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make `_logger.isDebugEnabled()` condition false in Junit?

How to make _logger.isDebugEnabled() condition false in Junit ?

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

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

i tried to my knowledge i can't do it , Please let me know if anyone have done this .

like image 386
Vishnu Ranganathan Avatar asked Sep 10 '25 10:09

Vishnu Ranganathan


1 Answers

You can set level = OFF programmatically in unit test:

    Logger.getRootLogger().setLevel(Level.OFF);
like image 187
Evgeniy Dorofeev Avatar answered Sep 13 '25 00:09

Evgeniy Dorofeev