Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

ranger HDFS Audit to local file log4j error

ranger HDFS Audit to local file log4j error

Expert Contributor

Hello,

I try to configure ranger HDFS Audit to local file from this instruction https://cwiki.apache.org/confluence/display/RANGER/Ranger+0.5+Audit+Configuration

My setting:

xasecure.audit.log4j.is.enabled=true

xasecure.audit.destination.log4j=true

xasecure.audit.destination.log4j.logger=xaaudit


ranger.logger=INFO,console,RANGERAUDIT

log4j.logger.xaaudit=${ranger.logger}

log4j.appender.RANGERAUDIT=org.apache.log4j.DailyRollingFileAppender

log4j.appender.RANGERAUDIT.File=/tmp/ranger_hdfs_audit.log

log4j.appender.RANGERAUDIT.layout=org.apache.log4j.PatternLayout

log4j.appender.RANGERAUDIT.layout.ConversionPattern=%d{ISO8601} %p %c{2}: %L %m%n

log4j.appender.RANGERAUDIT.DatePattern=.yyyy-MM-dd



I have an error into console when enter any command under not hdfs user. For example:

hdfs dfs -ls /

log4j:ERROR setFile(null,true) call failed.

java.io.FileNotFoundException: /tmp/ranger_hdfs_audit.log (Permission denied)

at java.io.FileOutputStream.open0(Native Method)

at java.io.FileOutputStream.open(FileOutputStream.java:270)

at java.io.FileOutputStream.<init>(FileOutputStream.java:213)

at java.io.FileOutputStream.<init>(FileOutputStream.java:133)

at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)

at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)

at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)

at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)

at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)

at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)

at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)

at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)

at org.apache.log4j.PropertyConfigurator.parseCatsAndRenderers(PropertyConfigurator.java:672)

at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:516)

at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:580)

at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:526)

at org.apache.log4j.LogManager.<clinit>(LogManager.java:127)

at org.apache.log4j.Logger.getLogger(Logger.java:104)

at org.apache.commons.logging.impl.Log4JLogger.getLogger(Log4JLogger.java:262)

at org.apache.commons.logging.impl.Log4JLogger.<init>(Log4JLogger.java:108)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(LogFactoryImpl.java:1025)

at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(LogFactoryImpl.java:790)

at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:541)

at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:292)

at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:269)

at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:657)

at org.apache.hadoop.fs.FsShell.<clinit>(FsShell.java:43)

log4j:ERROR Either File or DatePattern options are not set for appender [RANGERAUDIT].

1 REPLY 1

Re: ranger HDFS Audit to local file log4j error

New Contributor

Hi @Ruslan Fialkovsky

Is your /tmp/ranger_hdfs_audit.log file got write permission for hdfs (linux) user ?