i have a spring boot application running in tomcat. To load the application properties I use the following construct:
@Configuration
@PropertySource("file:/opt/tomcat/latest/conf/application.properties")
class JpaConfig {
}
In the application.properties file I have the following logging options:
logging.file.path=/opt/tomcat/latest/logs
logging.file.name=/opt/tomcat/latest/logs/mylog.log
logging.level.org.springframework.web=debug
logging.level.com.myapp=debug
My problem is that the log file mylog.log is not being created when the application starts. I thought that it is a problem of permissions but the logs folder has the same owner and group as the springboot application.
I tried also to build the properties directly when the application runs in code, but that did not change anything:
fun main(args: Array<String>) {
val springApplication = SpringApplication(DemoApplication::class.java)
val properties = Properties()
properties["logging.file.name"] = "/opt/tomcat/latest/logs/mylog.log"
properties["logging.file.path"] = "/opt/tomcat/latest/logs/"
properties["logging.level.org.springframework.web"] = "debug"
properties["logging.level.com.myapp"] = "debug"
springApplication.setDefaultProperties(properties)
springApplication.run(*args)
}
Other possible idea that I found on the web was to use logback-spring.xml. That I did not try. I hope that there is a simpler explanation and solution to this problem. What can still be wrong with my configuration ? Can I see somehow in some error log what happens when trying to create the log file ? I use ubuntu on my server.