This tutorial will teach you how to configure your Spring Boot application to log messages to a file.
Specify File Path
To make your application log messages to a file, you will need to configure a couple of new properties in the application.properties file.
logging.file.path=/path/to/a/file logging.file.name=log.txt
You might also need to enable a specific logging level for your application. To do that, add the following configuration property to an application.properties file.
logging.level.<logger>=DEBUG
Where logger is the root package of your Spring Boot application. For example, if the root package of my Spring Boot application is com.appsdeveloperblog then the logging.level configuration will look for me as below.
logging.level.com.appsdeveloperblog=DEBUG
Video Tutorial
I hope this short tutorial was helpful to you.
If you are interested in learning more about building RESTful Web Services and Microservices with Spring Boot and Spring Cloud, please look at my complete video course: Spring Boot Microservices and Spring Cloud.