how to read environment variable or property in logback.xml and print that property in every log line

为君一笑 提交于 2021-01-29 04:02:45

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!