How to enable/setup log4j for oozi java workflows?

╄→尐↘猪︶ㄣ 提交于 2019-12-24 00:47:22

问题


I'm running an Oozie Java workflow (the jar file is in HDFS), and I'd like to add logging functionality to my application. Does anybody know how to do it? Where should I put my "log4j.properties" file? How can I make log4j to output the log to a location in HDFS?


回答1:


Looking in this documentation, you can try adding oozie-log4j.properties in your oozie directory (where workflow.xml is).

Here are the default settings:

log4j.appender.oozie=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.oozie.RollingPolicy=org.apache.oozie.util.OozieRollingPolicy
log4j.appender.oozie.File=${oozie.log.dir}/oozie.log
log4j.appender.oozie.Append=true
log4j.appender.oozie.layout=org.apache.log4j.PatternLayout
log4j.appender.oozie.layout.ConversionPattern=%d{ISO8601} %5p %c{1}:%L - %m%n
log4j.appender.oozie.RollingPolicy.FileNamePattern=${log4j.appender.oozie.File}-%d{yyyy-MM-dd-HH}
log4j.appender.oozie.RollingPolicy.MaxHistory=720

It also outlines the following restrictions:

In order for Oozie logging to work 100% correctly, the following restrictions must be observed (described below and in the oozie-log4j.properties file):

  • The appender that Oozie uses must be named "oozie" (i.e. log4j.appender.oozie )

  • log4j.appender.oozie.RollingPolicy.FileNamePattern must end with "-%d{yyyy-MM-dd-HH}.gz" or "-%d{yyyy-MM-dd-HH}". If it ends with ".gz" the old logs will be compressed when rolled

  • log4j.appender.oozie.RollingPolicy.FileNamePattern must start with the value of log4j.appender.oozie.File



来源:https://stackoverflow.com/questions/40405538/how-to-enable-setup-log4j-for-oozi-java-workflows

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!