I have a spring boot application with a micro services architecture. With something like 10 spring boot containers running.
The setup for loading the logback.xml that I am aiming to do is looks something like this.
How do I mount and load the logback.xml on a spring boot embedded jar / container when I start the containers up.
My thoughts are something like this.
This will run the spring boot app ok.
docker run -d --name=app1 app_image
Something like this is what I am looking to implement load the logback.xml
docker run -d --name=app1 --volume=/home/host-path/log-back-conig-dir/:/container-app-dir/ app_image
docker run -d --name=app2 --volume=/home/host-path/log-back-conig-dir/:/container-app-dir/ app_image
docker run -d --name=app3 --volume=/home/host-path/log-back-conig-dir:/container-app-dir/
Further info
I am using the Dockerfile example taken from the official spring boot
spring.io/guides/gs/spring-boot-docker
Dockerfile
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ARG JAR_FILE
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
logback.xml looks like this
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty scope="context" name="springAppName" source="spring.application.name"/>
<include resource="org/springframework/boot/logging/logback/base.xml" />
<springProfile name="default,dev,staging">
<logger name="guru.springframework.controllers" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE" />
</logger>
</springProfile>
<springProfile name="dev">
<appender name="stash" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<file>/varlog/log-tracing-demo/build/logs/${springAppName}.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/var/log/log-tracing-demo/build/logs/${springAppName}.log.%d{yyyy-MM-dd}</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder class="net.logstash.logback.encoder.LogstashEncoder" >
<includeContext>false</includeContext>
<fieldNames>
<message>msg</message>
</fieldNames>
<customFields>{"application_name":"${springAppName}"}</customFields>
</encoder>
</appender>
<root level="info">
<appender-ref ref="CONSOLE" />
<appender-ref ref="stash" />
</root>
</springProfile>
</configuration>
Short version of question is..
How do make multiple spring boot docker containers to mount and share the same single logback.xml file.