美文网首页
修改伪分布Hadoop进程日志为JSON格式

修改伪分布Hadoop进程日志为JSON格式

作者: 喵星人ZC | 来源:发表于2019-06-24 00:06 被阅读0次

    Hadoop版本:2.6.0-cdh5.7.0

    1、到Hadoop配置文件目录

    cd $HADOOP_HOME/etc/hadoop
    

    2、修改log4j.properties

    注释第45行
     45 #log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n
    -----------------------------------------------------------------------------------------------------------------------------
    添加一行
     log4j.appender.RFA.layout.ConversionPattern={"time":"%d{yyyy-MM-dd HH:mm:ss,SSS}","logtype":"%p","loginfo":"%c:%m"}%n
    

    3、重启Hadoop,然后查看日志格式

    cd $HADOOP_HOME/logs
    
    tail -200f hadoop-hadoop-namenode-hadoop000.log
    
    {"time":"2019-06-24 00:00:28,935","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Scanned 0 directive(s) and 0 block(s) in 1 millisecond(s)."}
    {"time":"2019-06-24 00:00:58,935","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Rescanning after 30001 milliseconds"}
    {"time":"2019-06-24 00:00:58,936","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Scanned 0 directive(s) and 0 block(s) in 1 millisecond(s)."}
    {"time":"2019-06-24 00:01:28,936","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Rescanning after 30001 milliseconds"}
    {"time":"2019-06-24 00:01:28,937","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Scanned 0 directive(s) and 0 block(s) in 1 millisecond(s)."}
    {"time":"2019-06-24 00:01:58,937","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Rescanning after 30001 milliseconds"}
    {"time":"2019-06-24 00:01:58,938","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Scanned 0 directive(s) and 0 block(s) in 1 millisecond(s)."}
    {"time":"2019-06-24 00:02:28,937","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Rescanning after 30000 milliseconds"}
    {"time":"2019-06-24 00:02:28,938","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Scanned 0 directive(s) and 0 block(s) in 1 millisecond(s)."}
    {"time":"2019-06-24 00:02:58,939","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Rescanning after 30002 milliseconds"}
    {"time":"2019-06-24 00:02:58,940","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Scanned 0 directive(s) and 0 block(s) in 1 millisecond(s)."}
    {"time":"2019-06-24 00:03:28,941","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Rescanning after 30002 milliseconds"}
    {"time":"2019-06-24 00:03:28,942","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Scanned 0 directive(s) and 0 block(s) in 1 millisecond(s)."}
    {"time":"2019-06-24 00:03:58,943","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Rescanning after 30002 milliseconds"}
    {"time":"2019-06-24 00:03:58,944","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Scanned 0 directive(s) and 0 block(s) in 1 millisecond(s)."}
    {"time":"2019-06-24 00:04:28,944","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Rescanning after 30001 milliseconds"}
    {"time":"2019-06-24 00:04:28,945","logtype":"INFO","loginfo":"org.apache.hadoop.hdfs.server.blockmanagement.CacheReplicationMonitor:Scanned 0 directive(s) and 0 block(s) in 1 millisecond(s)."}
    

    相关文章

      网友评论

          本文标题:修改伪分布Hadoop进程日志为JSON格式

          本文链接:https://www.haomeiwen.com/subject/lrsgqctx.html