0

I am trying to log the properties mentioned in application.properties using logback.

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

expected out is :

13:10:52.193 [main] [myservice]DEBUG - Execution of method runends : return value -> null

How can this be achieved?

Rajeev Akotkar
  • 1,377
  • 4
  • 26
  • 46

1 Answers1

0

You can use property in the pattern

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.

11:15:23.474 [main] myservice INFO - Tomcat initialized with port(s): 8080 (http)

Ankit Kanani
  • 104
  • 1
  • 3
  • I cannot do that as I am developing a logging utility and consuming application needs to have the appName in its application.properties/yml – Rajeev Akotkar Feb 21 '19 at 05:54