if (System.getProperty("hadoop.log.dir") == null
&& System.getenv("HADOOP_LOG_DIR") != null)
System.setProperty("hadoop.log.dir", System.getenv("HADOOP_LOG_DIR"));
// wrap the command in a stdout/stderr capture
TaskAttemptID taskid = TaskAttemptID.forName(job.get("mapred.task.id"));
File stdout = TaskLog.getTaskLogFile(taskid, false, TaskLog.LogName.STDOUT);
File stderr = TaskLog.getTaskLogFile(taskid, false, TaskLog.LogName.STDERR);
long logLength = TaskLog.getTaskLogLength(job);
command = TaskLog.captureOutAndError(null, command, stdout, stderr, logLength, false);
stdout.getParentFile().mkdirs();