下面是关于用javaapi创建yarnapp的例子。https://github.com/hortonworks/simple-yarn-app工作正常,但是,日志只存在于执行之后,日志就消失了。我怎么能用密码抓到这个?或者启用一个选项?
bxpogfeg1#
应用程序完成后,您可以使用logclihelpers按应用程序id查找日志:
import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.hadoop.security.UserGroupInformation; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext; import org.apache.hadoop.yarn.client.api.YarnClientApplication; import org.apache.hadoop.yarn.conf.YarnConfiguration; import org.apache.hadoop.yarn.exceptions.YarnException; import org.apache.hadoop.yarn.logaggregation.LogCLIHelpers; import java.io.IOException; import java.io.PrintStream; public static void getLogs(YarnConfiguration conf, YarnClientApplication app) throws IOException, YarnException { ApplicationSubmissionContext appContext = app.getApplicationSubmissionContext(); ApplicationId appId = appContext.getApplicationId(); LogCLIHelpers logCLIHelpers = new LogCLIHelpers(); logCLIHelpers.setConf(conf); FileSystem fs = FileSystem.get(conf); Path logFile = new Path("/path/to/log/file.log"); fs.create(logFile, false); try (PrintStream printStream = new PrintStream(logFile.toString())) { logCLIHelpers.dumpAllContainersLogs(appId, UserGroupInformation.getCurrentUser().getShortUserName(), printStream); } }
1条答案
按热度按时间bxpogfeg1#
应用程序完成后,您可以使用logclihelpers按应用程序id查找日志: