code: public void setAppender(final Appender appender) {
          if (this.appender != null) {
              close();
          }
          checkAccess(this);
          if (applyLayout && appender != null) {
              final Formatter formatter = getFormatter();
              appender.setLayout(formatter == null ? null : new FormatterLayout(formatter));
          }
          appenderUpdater.set(this, appender);
      }
docs: Set the Log4j appender.
  
  @param appender the log4j appender