code: public static LoggerContext getLoggerContext() {
          final long startTime = System.nanoTime();
          while (true) {
              final ILoggerFactory iLoggerFactory = LoggerFactory.getILoggerFactory();
              if (iLoggerFactory instanceof LoggerContext) {
                  return (LoggerContext) iLoggerFactory;
              }
              if ((System.nanoTime() - startTime) > LOGGER_CONTEXT_AWAITING_TIMEOUT.toNanoseconds()) {
                  throw new IllegalStateException("Unable to acquire the logger context");
              }
              try {
                  Thread.sleep(LOGGER_CONTEXT_AWAITING_SLEEP_TIME.toMilliseconds());
              } catch (InterruptedException e) {
                  throw new IllegalStateException(e);
              }
          }
      }
docs: Acquires the logger context.
  <p/>
  <p>It tries to correctly acquire the logger context in the multi-threaded environment.
  Because of the <a href="bug">http://jira.qos.ch/browse/SLF4J-167</a> a thread, that didn't
  start initialization has a possibility to get a reference not to a real context, but to a
  substitute.</p>
  <p>To work around this bug we spin-loop the thread with a sensible timeout, while the
  context is not initialized. We can't just make this method synchronized, because
  {@code  LoggerFactory.getILoggerFactory} doesn't safely publish own state. Threads can
  observe a stale state, even if the logger has been already initialized. That's why this
  method is not thread-safe, but it makes the best effort to return the correct result in
  the multi-threaded environment.</p>