Include the application name on each log line when it is available

Update Logback and Log4J2 so that they include the application name on
each log line. If `spring.application.name` had not been set, or if
`logging.include-application-name` is `false` then the name is not
logged.

Closes gh-35593
This commit is contained in:
Phillip Webb
2023-06-21 21:56:20 -07:00
parent c1b295fd71
commit 493777d3c9
15 changed files with 95 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
spring.application.name=sample
spring.security.user.name=user
spring.security.user.password=password
management.endpoint.shutdown.enabled=true

View File

@@ -2,7 +2,7 @@
<Configuration status="WARN" monitorInterval="30">
<Properties>
<Property name="PID">????</Property>
<Property name="LOG_PATTERN">%clr{%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n%xwEx</Property>
<Property name="LOG_PATTERN">%clr{%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}{faint} %clr{%5p} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{${sys:LOGGED_APPLICATION_NAME:-}[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n%xwEx</Property>
</Properties>
<Appenders>
<Console name="Console" target="SYSTEM_OUT" follow="true">

View File

@@ -1,3 +1,4 @@
spring.application.name=sample
service.name=Phil
spring.security.user.name=user