code: private String getRootLoggerDirectory() {
          String rootLoggerDirectory = null;
          org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger();
  
          Enumeration allAppenders = rootLogger.getAllAppenders();
          if (allAppenders != null) {
              while (allAppenders.hasMoreElements()) {
                  Appender appender = (Appender) allAppenders.nextElement();
                  if (appender instanceof FileAppender) {
                      FileAppender fileAppender = (FileAppender) appender;
                      String rootLoggerFile = fileAppender.getFile();
                      rootLoggerDirectory = new File(rootLoggerFile).getParent();
                      break;
                  }
              }
          }
          return rootLoggerDirectory;
      }
docs: Get the root logger file location under which the failed log messages will be written.
  
  Since this class is used in Hooks which run within JVMs of other components like Hive,
  we want to write the failed messages file under the same location as where logs from
  the host component are saved. This method attempts to get such a location from the
  root logger's appenders. It will work only if at least one of the appenders is a {@link FileAppender}
  
  @return directory under which host component's logs are stored.