title: "Logging system failed to initialize using configuration from 'null'" when running a Docker container on a local computer
body: <p>I have a simple Spring Boot API project that runs well when I execute a bootable jar file on my local machine or a docker image on Google Kubernetes Engine but emits errors when using <code>docker run</code> on my local machine. I built and executed the image like this:</p>
  <pre><code>docker build -t foo .
  docker run -p 8080:8080 -e SPRING_PROFILES_ACTIVE=local foo
  </code></pre>
  <p>Here is the error:</p>
  <pre><code>Logging system failed to initialize using configuration from 'null'
  java.lang.IllegalStateException: Logback configuration error detected:
  ERROR in ch.qos.logback.core.joran.spi.Interpreter@15:14 - RuntimeException in Action for tag [appender] java.lang.IllegalArgumentException: A project ID is required for this service but could not be determined from the builder or the environment.  Please set a project ID using the builder.
      at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
      at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
      at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
      at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:132)
      at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:312)
      at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281)
      at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
      at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
      at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
      at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
      at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
      at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
      at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
      at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
      at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
      at com.foo.FooApiApplication.main(FooApiApplication.java:20)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
      at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
  2021-05-17 06:34:46.358 ERROR 1 --- [           main] o.s.boot.SpringApplication               : Application run failed
  
  java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected:
  ERROR in ch.qos.logback.core.joran.spi.Interpreter@15:14 - RuntimeException in Action for tag [appender] java.lang.IllegalArgumentException: A project ID is required for this service but could not be determined from the builder or the environment.  Please set a project ID using the builder.
      at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:327)
      at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281)
      at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
      at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
      at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
      at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
      at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
      at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
      at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
      at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
      at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
      at com.foo.FooApiApplication.main(FooApiApplication.java:20)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
      at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
  Caused by: java.lang.IllegalStateException: Logback configuration error detected:
  ERROR in ch.qos.logback.core.joran.spi.Interpreter@15:14 - RuntimeException in Action for tag [appender] java.lang.IllegalArgumentException: A project ID is required for this service but could not be determined from the builder or the environment.  Please set a project ID using the builder.
      at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
      at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
      at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
      at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:132)
      at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:312)
      ... 26 common frames omitted
  
  Exception in thread &quot;main&quot; java.lang.reflect.InvocationTargetException
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
      at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
      at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
  Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected:
  ERROR in ch.qos.logback.core.joran.spi.Interpreter@15:14 - RuntimeException in Action for tag [appender] java.lang.IllegalArgumentException: A project ID is required for this service but could not be determined from the builder or the environment.  Please set a project ID using the builder.
      at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:327)
      at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281)
      at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239)
      at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
      at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
      at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
      at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
      at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
      at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
      at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
      at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
      at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1311)
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300)
      at com.foo.FooApiApplication.main(FooApiApplication.java:20)
      ... 8 more
  Caused by: java.lang.IllegalStateException: Logback configuration error detected:
  ERROR in ch.qos.logback.core.joran.spi.Interpreter@15:14 - RuntimeException in Action for tag [appender] java.lang.IllegalArgumentException: A project ID is required for this service but could not be determined from the builder or the environment.  Please set a project ID using the builder.
      at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179)
      at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80)
      at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60)
      at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:132)
      at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:312)
      ... 26 more
  </code></pre>
  <p><code>logback-spring.xml</code>:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;configuration&gt;
      &lt;include resource=&quot;com/google/cloud/spring/logging/logback-appender.xml&quot;/&gt;
      &lt;include resource=&quot;com/google/cloud/spring/logging/logback-json-appender.xml&quot;/&gt;
      &lt;include resource=&quot;org/springframework/boot/logging/logback/defaults.xml&quot;/&gt;
      &lt;include resource=&quot;org/springframework/boot/logging/logback/console-appender.xml&quot;/&gt;
  
      &lt;springProfile name=&quot;!dev&quot;&gt;
          &lt;!-- This is for the local environment --&gt;
          &lt;root level=&quot;INFO&quot;&gt;
              &lt;appender-ref ref=&quot;CONSOLE&quot;/&gt;
          &lt;/root&gt;
      &lt;/springProfile&gt;
  
      &lt;springProfile name=&quot;dev&quot;&gt;
          &lt;root level=&quot;INFO&quot;&gt;
              &lt;appender-ref ref=&quot;CONSOLE_JSON&quot;/&gt;
          &lt;/root&gt;
      &lt;/springProfile&gt;
  &lt;/configuration&gt;
  </code></pre>
  <p>And <code>DockerFile</code>:</p>
  <pre><code>ARG APP_NAME=foo
  ARG APP_HOME=/foo
  
  FROM openjdk:11-jdk-slim AS build
  USER root
  ARG APP_HOME
  WORKDIR ${APP_HOME}/
  COPY . .
  RUN chmod +x gradlew
  RUN ./gradlew build --no-daemon -i --stacktrace -x test
  
  FROM openjdk:11-jdk-slim
  ARG APP_NAME
  ARG APP_HOME
  WORKDIR ${APP_HOME}/
  COPY --from=build ${APP_HOME}/build/libs/${APP_NAME}.jar ./${APP_NAME}.jar
  EXPOSE 8080
  ENTRYPOINT [&quot;java&quot;,&quot;-jar&quot;,&quot;/foo/foo.jar&quot;]
  </code></pre>
  <p>How to fix this error from my local computer?</p>