private void addAutoInstanceDefinition(ViewEntity viewEntity) {
    ViewConfig viewConfig = viewEntity.getConfiguration();
    String viewName = viewEntity.getViewName();

    AutoInstanceConfig autoInstanceConfig = viewConfig.getAutoInstance();
    if (autoInstanceConfig == null) {
      return;
    }

    List<String> services = autoInstanceConfig.getServices();
    Collection<String> roles = autoInstanceConfig.getRoles();

    Map<String, org.apache.ambari.server.state.Cluster> allClusters = clustersProvider.get().getClusters();
    for (org.apache.ambari.server.state.Cluster cluster : allClusters.values()) {

      String clusterName = cluster.getClusterName();
      Long clusterId = cluster.getClusterId();
      Set<String> serviceNames = cluster.getServices().keySet();

      for (String service : services) {
        try {
          Service svc = cluster.getService(service);
          StackId stackId = svc.getDesiredStackId();
          if (checkAutoInstanceConfig(autoInstanceConfig, stackId, service, serviceNames)) {
            installAutoInstance(clusterId, clusterName, cluster.getService(service), viewEntity, viewName, viewConfig, autoInstanceConfig, roles);
          }
        } catch (Exception e) {
          LOG.error("Can't auto create instance of view " + viewName + " for cluster " + clusterName +
              ".  Caught exception :" + e.getMessage(), e);
        }
      }
    }
  }
copies non-log4j properties (like ambari.log.dir) from ambari's log4j.properties into view's log4j properties
and removes log4j specific properties (log4j.rootLogger) inside ambari's log4j.properties from view's log4j properties
It then configures the log4j with view's properties.

@param viewDefinition
@param cl
ambari-server/src/main/java/org/apache/ambari/server/view/ViewRegistry.java