Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ public class TestOzoneAuditLogger {

static {
System.setProperty("log4j.configurationFile", "auditlog.properties");
System.setProperty("log4j2.contextSelector",
"org.apache.logging.log4j.core.async.AsyncLoggerContextSelector");
}

private static final AuditLogger AUDIT =
Expand Down Expand Up @@ -115,7 +117,7 @@ public static void tearDown() {
public void verifyDefaultLogLevelForSuccess() throws IOException {
AUDIT.logWriteSuccess(WRITE_SUCCESS_MSG);
String expected =
"INFO | OMAudit | " + WRITE_SUCCESS_MSG.getFormattedMessage();
"INFO | OMAudit | ? | " + WRITE_SUCCESS_MSG.getFormattedMessage();
verifyLog(expected);
}

Expand All @@ -126,7 +128,7 @@ public void verifyDefaultLogLevelForSuccess() throws IOException {
public void verifyDefaultLogLevelForFailure() throws IOException {
AUDIT.logWriteFailure(WRITE_FAIL_MSG);
String expected =
"ERROR | OMAudit | " + WRITE_FAIL_MSG.getFormattedMessage();
"ERROR | OMAudit | ? | " + WRITE_FAIL_MSG.getFormattedMessage();
verifyLog(expected);
}

Expand Down Expand Up @@ -168,7 +170,7 @@ public void messageIncludesMultilineException() throws IOException {
.withException(testException).build();
AUDIT.logWriteFailure(exceptionAuditMessage);
verifyLog(
"ERROR | OMAudit | user=john | "
"ERROR | OMAudit | ? | user=john | "
+ "ip=192.168.0.1 | op=CREATE_VOLUME "
+ "{key1=value1, key2=value2} | ret=FAILURE",
"org.apache.hadoop.ozone.audit."
Expand Down
2 changes: 1 addition & 1 deletion hadoop-hdds/common/src/test/resources/auditlog.properties
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ appender.audit.type = File
appender.audit.name = AUDITLOG
appender.audit.fileName=audit.log
appender.audit.layout.type=PatternLayout
appender.audit.layout.pattern= %-5level | %c{1} | %msg%n
appender.audit.layout.pattern= %-5level | %c{1} | %C | %msg%n

loggers=audit
logger.audit.type=AsyncLogger
Expand Down
3 changes: 3 additions & 0 deletions hadoop-ozone/dist/src/shell/ozone/ozone
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ function ozonecmd_case
# exception as mentioned in HDDS-3812
hadoop_deprecate_envvar HDDS_DN_OPTS OZONE_DATANODE_OPTS
OZONE_DATANODE_OPTS="-Dorg.apache.ratis.thirdparty.io.netty.allocator.useCacheForAllThreads=false -Dorg.apache.ratis.thirdparty.io.netty.leakDetection.level=disabled -Dlog4j.configurationFile=${HADOOP_CONF_DIR}/dn-audit-log4j2.properties ${OZONE_DATANODE_OPTS}"
OZONE_DATANODE_OPTS="-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector ${OZONE_DATANODE_OPTS}"
HADOOP_CLASSNAME=org.apache.hadoop.ozone.HddsDatanodeService
OZONE_RUN_ARTIFACT_NAME="hadoop-ozone-datanode"
;;
Expand Down Expand Up @@ -156,6 +157,7 @@ function ozonecmd_case
HADOOP_CLASSNAME=org.apache.hadoop.ozone.om.OzoneManagerStarter
hadoop_deprecate_envvar HDFS_OM_OPTS OZONE_OM_OPTS
OZONE_OM_OPTS="${OZONE_OM_OPTS} -Dlog4j.configurationFile=${HADOOP_CONF_DIR}/om-audit-log4j2.properties"
OZONE_OM_OPTS="-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector ${OZONE_OM_OPTS}"
OZONE_RUN_ARTIFACT_NAME="hadoop-ozone-ozone-manager"
;;
sh | shell)
Expand All @@ -174,6 +176,7 @@ function ozonecmd_case
HADOOP_CLASSNAME='org.apache.hadoop.hdds.scm.server.StorageContainerManagerStarter'
hadoop_deprecate_envvar HDFS_STORAGECONTAINERMANAGER_OPTS OZONE_SCM_OPTS
OZONE_SCM_OPTS="${OZONE_SCM_OPTS} -Dlog4j.configurationFile=${HADOOP_CONF_DIR}/scm-audit-log4j2.properties"
OZONE_SCM_OPTS="-Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector ${OZONE_SCM_OPTS}"
OZONE_RUN_ARTIFACT_NAME="hadoop-hdds-server-scm"
;;
s3g)
Expand Down