Custom logging
In a cases when you need to override default Metarank logging configuration, you may need to build a custom docker image, based on an original upstream one from Metarank.
Metarank uses the following entrypoint for the docker container:
#!/bin/bash
set -euxo pipefail
OPTS=${JAVA_OPTS:-"-Xmx1g -verbose:gc"}
exec /usr/bin/java $OPTS -cp "/app/*" ai.metarank.main.Main "$@"
So you should note the following configuration toggles here:
env variable JAVA_OPTS can be used to pass custom JVM flags, like path to a custom logger configuration.
by default Metarank loads all the JAR files found in the
/app/directory.
Example: logstash-logback-encoder
To enable structured logging via logstash-logback-encoder, you can build a custom Docker image with the following Dockerfile:
FROM metarank/metarank:0.7.9-amd64
# add logback configuration file to the image
ADD logback.xml /app/
# add the logstash-logback-encoder with all its runtime dependencies to the classpath
ADD https://repo1.maven.org/maven2/net/logstash/logback/logstash-logback-encoder/7.4/logstash-logback-encoder-7.4.jar /app/
ADD https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/2.16.0/jackson-core-2.16.0.jar /app/
ADD https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/2.16.0/jackson-databind-2.16.0.jar /app/
# override default logback configuration
ENV JAVA_OPTS="-Xmx1g -Dlogback.configurationFile=/app/logback.xml -Dlogback.debug=true"
Such a custom image will successfully load the custom conviguration with non-default appender:
Last updated
Was this helpful?