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:
@@ -293,7 +293,7 @@ task runSpringApplicationExample(type: org.springframework.boot.build.docs.Appli
|
||||
task runLoggingFormatExample(type: org.springframework.boot.build.docs.ApplicationRunner) {
|
||||
classpath = configurations.springApplicationExample + sourceSets.main.output
|
||||
mainClass = "org.springframework.boot.docs.features.springapplication.MyApplication"
|
||||
args = ["--spring.main.banner-mode=off", "--server.port=0"]
|
||||
args = ["--spring.main.banner-mode=off", "--server.port=0", "--spring.application.name=myapp"]
|
||||
output = file("$buildDir/example-output/logging-format.txt")
|
||||
expectedLogging = "Started MyApplication in "
|
||||
normalizeTomcatPort()
|
||||
|
||||
@@ -31,6 +31,7 @@ The following items are output:
|
||||
* Log Level: `ERROR`, `WARN`, `INFO`, `DEBUG`, or `TRACE`.
|
||||
* Process ID.
|
||||
* A `---` separator to distinguish the start of actual log messages.
|
||||
* Application name: Enclosed in square brackets (logged by default only if configprop:spring.application.name[] is set)
|
||||
* Thread name: Enclosed in square brackets (may be truncated for console output).
|
||||
* Correlation ID: If tracing is enabled (not shown in the sample above)
|
||||
* Logger name: This is usually the source class name (often abbreviated).
|
||||
@@ -39,6 +40,7 @@ The following items are output:
|
||||
NOTE: Logback does not have a `FATAL` level.
|
||||
It is mapped to `ERROR`.
|
||||
|
||||
TIP: If you have a configprop:spring.application.name[] property but don't want it logged you can set configprop:logging.include-application-name[] to `false`.
|
||||
|
||||
|
||||
[[features.logging.console-output]]
|
||||
|
||||
Reference in New Issue
Block a user