step做完文件检验后,还想在job执行后打印log如何实现
时间: 2023-12-28 10:04:15 浏览: 29
可以通过以下两种方式来实现:
1. 使用log4j或者其他日志框架记录日志,将日志输出到文件中,然后在Job执行完之后读取文件内容进行打印。
2. 在Job执行完之后,通过使用Job的getCounters方法获取Job执行过程中的计数器信息,然后通过日志的方式打印出来。例如:
```
Job job = new Job(conf, "myJob");
// 设置Job的输入路径和输出路径等信息
...
if(job.waitForCompletion(true)) {
// Job执行完后打印计数器信息
Counters counters = job.getCounters();
long inputRecords = counters.findCounter(TaskCounter.MAP_INPUT_RECORDS).getValue();
long outputRecords = counters.findCounter(TaskCounter.MAP_OUTPUT_RECORDS).getValue();
long reduceInputRecords = counters.findCounter(TaskCounter.REDUCE_INPUT_RECORDS).getValue();
long reduceOutputRecords = counters.findCounter(TaskCounter.REDUCE_OUTPUT_RECORDS).getValue();
LOG.info("inputRecords: " + inputRecords);
LOG.info("outputRecords: " + outputRecords);
LOG.info("reduceInputRecords: " + reduceInputRecords);
LOG.info("reduceOutputRecords: " + reduceOutputRecords);
}
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)