'How to read spring boot application.yml properties in log4j2.yml
I want to read log path from application.yml and use is in log4j2.yml Is this possible? If yes, how?
example:
application.yml
log:
Path: logs/app.log
log4j2.yml
RollingFile:
name: LogToRollingFile
fileName: ${log.path}
Solution 1:[1]
Use Log4j 2.13.0 or 2.13.1. It contains a log4j-spring-cloud-config-client jar. Include that in your application. Once you do that you can use the Spring Lookup to include properties from your application.yml in log4j2.xml. this example from Logging in the Cloud shows how to used the Spring, Docker, and Kubernetes Lookups.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | rgoers |