`org.apache.log4j.spi.LoggerContext` does not exist in Log4j 2. That is a Log4j 1 class. There is no need to do that check here. `org.apache.logging.log4j.spi.AbstractLogger` is sufficient because it is guaranteed to exist in Log4j 2 and NOT exist in Log4j 1.