Skip to content

Commit

Permalink
close #2581
Browse files Browse the repository at this point in the history
GRPC Java defaults to using java. til.logging (JUL) as the logging framework. In order to print logs using log4j2.xml configuration rules, the dependency Bridge from JUL to Log4j is used
  • Loading branch information
haohao0103 committed Jul 15, 2024
1 parent 03b40a5 commit 189d1ed
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ if [ $(ps -ef|grep -v grep| grep java|grep -cE ${CONF}) -ne 0 ]; then
fi
echo "Starting HugeGraphPDServer..."

JVM_OPTIONS="-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager"

# Turn on security check
exec ${JAVA} -Dname="HugeGraphPD" ${JAVA_OPTIONS} -jar \
exec ${JAVA} -Dname="HugeGraphPD" ${JVM_OPTIONS} ${JAVA_OPTIONS} -jar \
-Dspring.config.location=${CONF}/application.yml ${LIB}/hg-pd-service-*.jar >> ${OUTPUT} 2>&1 &

PID="$!"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<!-- Use mixed async way to output logs -->
<logger name="org.apache.hugegraph" level="INFO" additivity="false">
<appender-ref ref="file" />
<appender-ref ref="console" />
<!-- <appender-ref ref="console" />-->
</logger>
</loggers>
</configuration>
7 changes: 6 additions & 1 deletion hugegraph-pd/hg-pd-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@
<version>2.7</version>
<scope>compile</scope>
</dependency>

<!-- Bridge from JUL to Log4j -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
<version>2.17.2</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ case "$GC_OPTION" in
exit 1
esac

JVM_OPTIONS="-Dlog4j.configurationFile=${CONF}/log4j2.xml -Dfastjson.parser.safeMode=true"
JVM_OPTIONS="-Dlog4j.configurationFile=${CONF}/log4j2.xml -Dfastjson.parser.safeMode=true -Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager"

if [ "${OPEN_TELEMETRY}" == "true" ]; then
OT_JAR="opentelemetry-javaagent.jar"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<!-- Use mixed async way to output logs -->
<logger name="org.apache.hugegraph" level="INFO" additivity="false">
<appender-ref ref="file"/>
<appender-ref ref="console"/>
<!-- <appender-ref ref="console"/>-->
</logger>
</loggers>
</configuration>
6 changes: 6 additions & 0 deletions hugegraph-store/hg-store-node/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@
<artifactId>log4j-api</artifactId>
<version>2.17.2</version>
</dependency>
<!-- Bridge from JUL to Log4j -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-jul</artifactId>
<version>2.17.2</version>
</dependency>
<!-- module end -->
</dependencies>

Expand Down

0 comments on commit 189d1ed

Please sign in to comment.