0

I'm currently dealing with external logging properties for the application I'm building. I have a custom properties file called myapp.properties. It contains some custom properties and some environment-specific Spring properties like SSL and server port(including logging).

The custom properties file works just fine for all properties, except for the logging.level.* properties, which are just plainly ignored.

For example, when I use this property in my custom myapp.properties:

server.port=12345.

It works just fine: s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 12345 (http)

However, when I try the same thing for the logging properties:

logging.level.root=ERROR

It still logs other messages: 2017-05-10 12:32:54.984 INFO 9188 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http).

Anyone knows what could possibly be a solution for this problem?

2
  • How have you told Spring Boot to use myapp.properties? Commented May 10, 2017 at 15:55
  • @AndyWilkinson using a PropertySourcesPlaceholderConfigurer. Commented May 11, 2017 at 7:38

2 Answers 2

2

Spring Boot initialises the logging system very early. So early, in fact, that a properties file that's configured via PropertySourcesPlaceholderConfigurer isn't available in time.

You have a few options including:

  • Configuring the logging level in the standard application.properties or application.yml files
  • Configuring spring.config.name so that Boot will look for myapp.properties either in addition to or in place of application.properties
Sign up to request clarification or add additional context in comments.

1 Comment

Hi Andy, I was already afraid of that. I already fixed the issue by creating two custom properties, one for the root logging level, and one for our own package logging level. I change the log level at run time using these two properties.
0

I asked, essentially, that question as issue on github. So here's solution. https://github.com/spring-projects/spring-boot/issues/9243

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.