code: public void logTaskFailed(TaskID taskId, String taskType, long time,
                              String error,
                              TaskAttemptID failedDueToAttempt) {
      if (disableHistory) {
        return;
      }
  
      JobID id = taskId.getJobID();
      if (!this.jobId.equals(id)) {
        throw new RuntimeException("JobId from task: " + id +
                                   " does not match expected: " + jobId);
      }
  
      if (null != writers) {
        String failedAttempt = failedDueToAttempt == null ?
            "" :
            failedDueToAttempt.toString();
        log(writers, RecordTypes.Task,
            new Keys[]{Keys.TASKID, Keys.TASK_TYPE,
                       Keys.TASK_STATUS, Keys.FINISH_TIME,
                       Keys.ERROR, Keys.TASK_ATTEMPT_ID},
            new String[]{ taskId.toString(),  taskType,
                          Values.FAILED.name(),
                          String.valueOf(time) , error,
                          failedAttempt});
      }
    }
docs: Log the task failure
  
  @param taskId the task that failed
  @param taskType the type of the task
  @param time the time of the failure
  @param error the error the task failed with
  @param failedDueToAttempt The attempt that caused the failure, if any