I have to configure logging for a Spring Boot application, but I don't know how I could use custom properties and JVM options in logback-spring.xml.
Let's say I have the following properties:
Then the filename and log entry should be the following:
As I know I cannot simply access to these properties in my logging configuration (spring-logback.xml). That's why I tried to create these beans (ConsoleAppender, RollingFileAppender) manually in a configuration class, but it didn't work for me. I also tried implementing the afterPropertiesSet method of InitializingBean and put these variables manually for Logback, but this didn't help either and I start running out of ideas. So any help is really appreciated!
Try to run app with this configurations where you can define the path to application.properties
and also provide the logback
configuration file.
$java -jar /{pathToJar}/myApp.jar
--spring.config.location=/{pathToFolderWithCustomeProperties}/application.properties
--logging.config=/{path}/logback.xml
-Dlogback.configurationFile=/{path}/logback.xml
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.