Skip to content

Improve documented logging property descriptions and default values #41933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mnisius opened this issue Aug 19, 2024 · 2 comments
Closed

Improve documented logging property descriptions and default values #41933

mnisius opened this issue Aug 19, 2024 · 2 comments
Assignees
Labels
type: documentation A documentation update
Milestone

Comments

@mnisius
Copy link

mnisius commented Aug 19, 2024

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 19, 2024
@wilkinsona
Copy link
Member

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.

@wilkinsona wilkinsona added the for: team-meeting An issue we'd like to discuss as a team to make progress label Aug 19, 2024
@philwebb
Copy link
Member

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.

@philwebb philwebb added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged for: team-meeting An issue we'd like to discuss as a team to make progress labels Aug 21, 2024
@philwebb philwebb added this to the 3.2.x milestone Aug 21, 2024
@philwebb philwebb changed the title The documentation of the default value of logging.pattern.console is not correct The default value of logging.pattern.console and logging.pattern.file in the metadata JSON is incorrect Aug 21, 2024
@philwebb philwebb changed the title The default value of logging.pattern.console and logging.pattern.file in the metadata JSON is incorrect Review logging properties in metadata JSON Aug 21, 2024
@wilkinsona wilkinsona changed the title Review logging properties in metadata JSON Improve logging property descriptions and default values Aug 21, 2024
@wilkinsona wilkinsona changed the title Improve logging property descriptions and default values Improve documented logging property descriptions and default values Aug 21, 2024
@wilkinsona wilkinsona self-assigned this Aug 21, 2024
@wilkinsona wilkinsona modified the milestones: 3.2.x, 3.2.9 Aug 21, 2024
izeye added a commit to izeye/spring-boot that referenced this issue Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

4 participants