Reports logging calls that are surrounded by a guard condition. This inspection can be used to adjust with a custom code style.

Example:


  public class TestObject {
    void test(Object object) {
      if(LOG.isDebugEnabled()){
        LOG.debug("some logging " + expensiveCalculation(1));
      }
    }
  }

After a quick-fix is applied:


  public class TestObject {
    void test(Object object) {
      LOG.debug("some logging " + expensiveCalculation(1));
    }
  }

This inspection supports Log4j2 and the SLF4J logging frameworks (except builders).

New in 2024.2