Hello, now that I'm able to set a custom default for logging.pattern.console i noticed that the documentation of the default value seems to be slightly incorrect.
By Default Log messages look like this:
2024-08-19T15:17:36.200+02:00 INFO 7876 --- [ restartedMain] d.c.operations.rest.RestServiceApp : Starting RestServiceApp using Java 21.0.4 with PID 7876 (D:\playground\event-test\target\classes started by user in D:\playground\event-test)
2024-08-19T15:17:36.202+02:00 INFO 7876 --- [ restartedMain] d.c.operations.rest.RestServiceApp : No active profile set, falling back to 1 default profile: "default"
The documentation says about logging.pattern.console :
Appender pattern for output to the console. Supported only with the default Logback setup.
Default: %clr(%d{${LOG_DATEFORMAT_PATTERN:-yyyy-MM-dd'T'HH:mm:ss. SSSXXX}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}
But ff I copy paste this value set this as the default the log looks like this:
-2024-08-19T15:51:14. 008+02:00 - INFO 17532 --- [ restartedMain] d.c.operations.rest.RestServiceApp : Starting RestServiceApp using Java 21.0.4 with PID 17532 (D:\playground\event-test\target\classes started by v108745 in D:\playground\event-test)
--2024-08-19T15:51:14. 010+02:00 - INFO 17532 --- [ restartedMain] d.c.operations.rest.RestServiceApp : No active profile set, falling back to 1 default profile: "default"
I after some tests I think this is the correct default:
%clr(%d{${LOG_DATEFORMAT_PATTERN:yyyy-MM-dd'T'HH:mm:ss.SSSXXX}}){faint} %clr(${LOG_LEVEL_PATTERN:%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}
this will produce the same log as if there is not custom config.
Comment From: wilkinsona
This is covered in a tip in Custom Log Configuration:
If you want to use a placeholder in a logging property, you should use Spring Boot’s syntax and not the syntax of the underlying framework. Notably, if you use Logback, you should use : as the delimiter between a property name and its default value and not use :-.
If you pass the value straight into Logback, in logback.xml or logback-spring.xml for example, the documented default is correct. If you're configuring it via the environment then it's not. We'll discuss this one as a team and decide what, if anything, we might be able to do to make the documented default more useful.
Comment From: philwebb
The default value isn't really correct because it differs depending on the logging system. We're going to remove the default value from the metadata JSON file.