I am trying to exclude all internal spring boot logs inside my docker container but for some reason I can't.
I tried a lot of things, for example the following commands inside my application.properties file:
logging.level.\*=OFF
or logging.level.org.springframework=OFF
or logging.level.root=OFF
, but they not worked, inside docker container a see next logs (part of them):
2024-07-31 16:42:00 13:42:00.775 [main] INFO org.f1r3fly.Main -- Starting Main using Java 17.0.2 with PID 1 (/app/DiscordBot.jar started by root in /app)
2024-07-31 16:42:00 13:42:00.965 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory -- Autowiring by type from bean name 'jsonMixinModuleEntries' via factory method to bean named 'org.springframework.context.annotation.AnnotationConfigApplicationContext@3b2da18f'
I'm also tried to set JVM args inside my docker file:
# Set the command to run the application with logging turned off
CMD ["java", "-Dlogging.level.root=OFF", "-jar", "DiscordBot.jar", "--spring.config.location=/app/config/application.properties"]
but this approach also, didn't work.
Can someone help me, how I can set off all internal springboot logs for my docker container?
Spring Boot uses Logback as the default logging framework, so to exclude all internal Spring Boot logs inside your Docker container, you can try adding a logback.xml file to your project .
Under src/main/resources
create a logback.xml with this configuration:
<configuration>
<logger name="org.springframework" level="OFF" />
<logger name="org.springframework.boot" level="OFF" />
<root level="OFF">
<appender-ref ref="CONSOLE" />
</root>
</configuration>