mapreduce程序日志打印配置

1.在maven依赖里添加log4j

<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

2.配置 log4j.properties 文件(在Src->resources 中新建 log4j.properties)

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%-5p]%d{yyyy-MM-ddHH:mm:ss,SSS}method:%l%n%m%n

3.在主程序的main方法里添加

BasicConfigurator.configure();
    原文作者:沙漠的飞鱼
    原文地址: https://blog.csdn.net/a18813012617/article/details/76445435
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞