问题
I would like to read environment variable or property in every log line from logback.xml. Example if I hit echo "${FOO_INFO}" the result is "FOO_RESULT", this FOO_RESULT I need to print it in the every log line.
After adding JAVA_OPTS="-Dfoo.info=${FOO_INFO}"
I tried below option:-
Option : added and calling %d{ISO8601} [%thread] %-5level %logger{36} ${FOO_INFO}- %msg%n
回答1:
The documentation indicates you can include a system property by using a PatternLayout with the property conversion pattern %property{key}
where key
is the system property name.
来源:https://stackoverflow.com/questions/37667551/how-to-read-environment-variable-or-property-in-logback-xml-and-print-that-prope