[英]Spring Boot :Logback not picking values from application.properties
I am trying to log the properties mentioned in application.properties using logback. 我正在尝试使用logback记录application.properties中提到的属性。
application.properties appName=myservice logging.pattern.console=%d{HH:mm:ss.SSS} [%thread] %appName %-5level - %msg%n %ex application.properties appName = myservice logging.pattern.console =%d {HH:mm:ss.SSS} [%thread]%appName%-5level-%msg%n%ex
tried the above pattern and got the below output : 尝试了上述模式并获得了以下输出:
13:10:52.193 [main] [%PARSER_ERROR[appName]]DEBUG - Execution of method runends : return value -> null 13:10:52.193 [main] [%PARSER_ERROR [appName]]调试-方法runends的执行:返回值-> null
expected out is : 预期是:
13:10:52.193 [main] [myservice]DEBUG - Execution of method runends : return value -> null 13:10:52.193 [main] [myservice] DEBUG-方法runends的执行:返回值-> null
How can this be achieved? 如何做到这一点?
You can use property
in the pattern 您可以在模式中使用property
logging.pattern.console=%d{HH:mm:ss.SSS} [%thread] %property{KEY} %-5level - %msg%n %ex logging.pattern.console =%d {HH:mm:ss.SSS} [%thread]%property {KEY}%-5level-%msg%n%ex
For this, you have to add KEY in VM argument like -DKEY=myservice
. 为此,您必须在VM参数中添加KEY -DKEY=myservice
。
11:15:23.474 [main] myservice INFO - Tomcat initialized with port(s): 8080 (http) 11:15:23.474 [main] myservice INFO-Tomcat初始化时使用端口:8080(http)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.