Skip to content

Commit

Permalink
fix(hive): fix JSON logging (#421)
Browse files Browse the repository at this point in the history
  • Loading branch information
lyogev authored May 15, 2021
1 parent 4369db1 commit 9ece071
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 11 deletions.
7 changes: 1 addition & 6 deletions docker/hive/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ ENV AWS_JAVA_SDK_VERSION=1.7.4
RUN wget -q https://repo1.maven.org/maven2/com/amazonaws/aws-java-sdk/$AWS_JAVA_SDK_VERSION/aws-java-sdk-$AWS_JAVA_SDK_VERSION.jar \
&& mv aws-java-sdk-$AWS_JAVA_SDK_VERSION.jar $HIVE_HOME/lib

RUN wget -q https://repo1.maven.org/maven2/net/logstash/log4j/jsonevent-layout/1.7/jsonevent-layout-1.7.jar \
&& mv jsonevent-layout-1.7.jar $HIVE_HOME/lib
RUN wget -q https://repo1.maven.org/maven2/net/minidev/json-smart/1.1.1/json-smart-1.1.1.jar \
&& mv json-smart-1.1.1.jar $HIVE_HOME/lib

# Apache Atlas HiveHook installation
ENV ATLAS_VERSION=2.0.0
ENV HBASE_VERSION=2.0.2
Expand Down Expand Up @@ -87,7 +82,7 @@ COPY init-hive.sh /
COPY start-hive.sh /
COPY run_hive_import.sh /
COPY health-check.sh /
COPY log4j.json.properties .
COPY log4j2.json.properties .

RUN mkdir -p $ATLAS_HOME/hook-bin/
COPY atlas/import_hive.sh $ATLAS_HOME/hook-bin/
Expand Down
6 changes: 5 additions & 1 deletion docker/hive/init-hive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ HIVE_AUTH=${HIVE_AUTH:=NONE}

if [ ! -z ${JSON_LOG} ] ; then
echo "Setting Log type to JSON"
cat log4j.json.properties >> ${HIVE_HOME}/conf/hive-log4j.properties
cat log4j2.json.properties >> ${HIVE_HOME}/conf/hive-log4j2.properties
fi

cat >${HIVE_HOME}/conf/hive-site.xml <<EOL
Expand Down Expand Up @@ -89,6 +89,10 @@ cat >${HIVE_HOME}/conf/hive-site.xml <<EOL
See HIVE-4409 for more details.
</description>
</property>
<property>
<name>hive.async.log.enabled</name>
<value>false</value>
</property>
EOL

if [[ ! -z ${USE_ATLAS} ]] ; then
Expand Down
4 changes: 0 additions & 4 deletions docker/hive/log4j.json.properties

This file was deleted.

26 changes: 26 additions & 0 deletions docker/hive/log4j2.json.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# log4j2 internal log level
status = info
name = HiveLog2Config

filter.threshold.type = ThresholdFilter
filter.threshold.level = debug

appender.pattern.type = Console
appender.pattern.name = PatternAppender
appender.pattern.layout.type = PatternLayout
appender.pattern.layout.pattern = %d{HH:mm:ss.SSS} %highlight{%5p}{FATAL=red blink, ERROR=red, WARN=yellow bold, INFO=green, DEBUG=green bold, TRACE=blue} %style{[%t]}{magenta} %style{%c{2}}{cyan}: %m%n%wEx

appender.json.type = Console
appender.json.name = JsonAppender
appender.json.layout.type = JsonLayout
appender.json.layout.compact = true
appender.json.layout.eventEol = true
appender.json.layout.properties = true
appender.json.layout.locationInfo = false
appender.json.layout.includeStacktrace = true
appender.json.layout.stacktraceAsString = true
appender.json.layout.objectMessageAsJsonObject = false

rootLogger.level = ${env:LOG_LEVEL:-info}
rootLogger.appenderRefs = stdout
rootLogger.appenderRef.stdout.ref = JsonAppender

0 comments on commit 9ece071

Please sign in to comment.