I use Spring Boot and want it to write log output to a file.
According to the docs, this is simply done by setting
logging.file=filename.log
<
Sorry for the late reply. It seems spring's logger reads the property from its own classpath.Due to precedence, it's not respecting the properties supplied.
springApplication.setDefaultProperties(properties);
like thispublic static void main(String[] args) {
SpringApplication springApplication = new SpringApplication(MainClass.class);
Properties properties = new Properties();
properties.put("logging.file", logDirectory);
springApplication.setDefaultProperties(properties);
springApplication.run(args);
}
-Dlogging.file=/location/output.log
.Both of the above are not the best ones as in order to define other logging properties they also should follow the same way.
Define a property file and put all you logging configurations in that and specify the file in -Dspring.config.location
. This is a derivation of my other problem and this is how I resolved that. check that out in order to know other solutions that I've tried and their challenges.