if (logSR != null) {
if (logSR == null) {
  protected synchronized void doLog(String msg,                                  int level,                                  ServiceReference sr,                                  Throwable e )  {    if (bc!=null && log == null) {      logSR = bc.getServiceReference(LOG_CLASS_KF);      if (logSR != null) {        // No service implementing the Knopflerfish extended log, try to        // look for a standard OSGi log service.        logSR = bc.getServiceReference(LOG_CLASS_OSGI);      }      if (logSR != null) {        log = (org.osgi.service.log.LogService) bc.getService(logSR);      }      if (log == null) {        // Failed to get log service clear the service reference.        logSR = null;      }    }    if (log != null) {      log.log(sr, level, msg, e);    } else if (useOut||doWarnIfClosed) {      if (bc==null) {        System.err.println("WARNING! Bundle #"                           + bundleId                           + " called closed LogRef object");      }      // No log service and request for messages on System.out      System.out.print( LogUtil.fromLevel(level,8) );      System.out.print( " " );      if (simpleDateFormat == null) {        simpleDateFormat = new SimpleDateFormat ("yyyyMMdd HH:mm:ss");      }      System.out.print( simpleDateFormat.format(new Date()) );      System.out.print( " " );      System.out.print( getBundleName() );      System.out.print( " - " );      if (sr!=null) {        System.out.print( "[" );        System.out.print( sr );        System.out.print( "] " );      }      System.out.print( msg );      if (e!=null) {        System.out.print( " (" );        System.out.print( e );        System.out.print( ")" );	System.out.println();	e.printStackTrace();      }      System.out.println();    }  }