Skip to content

Commit

Permalink
Provide logback config for JSON logging to STDOUT
Browse files Browse the repository at this point in the history
Signed-off-by: nscuro <[email protected]>
  • Loading branch information
nscuro committed Aug 4, 2023
1 parent 059f21a commit a080708
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ RUN mkdir -p ${APP_DIR} ${DATA_DIR} \
COPY --from=jre-build /opt/java/openjdk $JAVA_HOME

# Copy the compiled WAR to the application directory created above
COPY ./target/${WAR_FILENAME} ${APP_DIR}
COPY ./target/${WAR_FILENAME} ./src/main/docker/logback-json.xml ${APP_DIR}

# Specify the user to run as (in numeric format for compatibility with Kubernetes/OpenShift's SCC)
USER ${UID}
Expand Down
22 changes: 22 additions & 0 deletions src/main/docker/logback-json.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
<appender name="JSON_STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>

<logger name="alpine" level="${dependencyTrack.logging.level:-INFO}" additivity="false">
<appender-ref ref="JSON_STDOUT" />
</logger>

<logger name="org.dependencytrack" level="${dependencyTrack.logging.level:-INFO}" additivity="false">
<appender-ref ref="JSON_STDOUT" />
</logger>

<logger name="org.eclipse.jetty" level="${dependencyTrack.logging.level:-INFO}" additivity="false">
<appender-ref ref="JSON_STDOUT" />
</logger>

<root level="WARN">
<appender-ref ref="JSON_STDOUT" />
</root>
</configuration>

0 comments on commit a080708

Please sign in to comment.