本文介绍了如何为oozi java工作流程启用/设置log4j?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个Oozie Java工作流程(jar文件位于HDFS中),我想为我的应用程序添加日志记录功能。有人知道该怎么做吗?我应该在哪里放置我的log4j.properties文件?我如何使log4j将日志输出到HDFS中的某个位置?

/oozie.apache.org/docs/3.3.0/AG_OozieLogging.htmlrel =nofollow noreferrer>本文档,您可以尝试添加 oozie-log4j.properties

以下是默认设置:<$ c $>您的oozie目录(其中 workflow.xml 是)。

/ p>

  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

它还概述了以下限制:




    Oozie使用的appender必须命名为oozie(即

  • log4j.appender.oozie.RollingPolicy.FileNamePattern 必须以 - %d {yyyy-MM-dd-HH} .gz - %d {yyyy-MM-dd-HH}。如果它以。gz结尾,则旧日志将在滚动时被压缩


  • log4j.appender.oozie.RollingPolicy.FileNamePattern 必须以 log4j.appender.oozie.File

    的值开头。 / li>

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?

解决方案

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:

  • 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

这篇关于如何为oozi java工作流程启用/设置log4j?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-15 22:08