Skip to content
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

Make it harder to misconfigure logging.threshold.console in yaml #40124

Closed
zman0900 opened this issue Mar 27, 2024 · 3 comments
Closed

Make it harder to misconfigure logging.threshold.console in yaml #40124

zman0900 opened this issue Mar 27, 2024 · 3 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@zman0900
Copy link

This was found using Spring Boot 3.2.4 and Java 21. Seems related to #36741.

Steps to reproduce

  1. Build jar for any Spring Boot app that is using the default logging setup - i.e. spring-boot-starter-logging with no logback.xml or other config files, just logging.* properties set in application.yml.
  2. Set logging.threshold.console to "off" in application.yml or application-{profile}.yml:
logging:
  threshold:
    console: off
  1. Run app: java -jar path/to/app.jar

Expected result

Only Spring banner printed to console, all logging goes to log file (if configured).

Actual result

All logging appears on console.

Observations

Running the app with this command instead produces expected result, with or without the same set in application.yml:
java -Dlogging.threshold.console=off -jar path/to/app.jar

Not sure if this could be relevant, but I noticed that the start() method is called directly on the ThresholdFilter, rather than using config.start(filter):
https://github.com/spring-projects/spring-boot/blob/v3.2.4/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/DefaultLogbackConfiguration.java#L108

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 27, 2024
@mhalbritter

This comment was marked as outdated.

@mhalbritter
Copy link
Contributor

mhalbritter commented Mar 28, 2024

Ah! It's a YAML thing.

logging.threshold.console: off

doesn't work.

logging.threshold.console: "off"

works.

YAML translates off to false, so make sure to quote it.

@mhalbritter mhalbritter added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 28, 2024
@mhalbritter mhalbritter closed this as not planned Won't fix, can't repro, duplicate, stale Mar 28, 2024
@philwebb philwebb changed the title Property logging.threshold.console is not effective unless set as Java system property Property logging.threshold.console is easy to misconfigure in yaml Apr 5, 2024
@philwebb philwebb reopened this Apr 5, 2024
@philwebb philwebb added type: enhancement A general enhancement and removed status: invalid An issue that we don't feel is valid labels Apr 5, 2024
@philwebb philwebb added this to the 3.3.x milestone Apr 5, 2024
@philwebb
Copy link
Member

philwebb commented Apr 5, 2024

I think we might be able to do more to protect against this. Perhaps we can automatically convert false to off

@wilkinsona wilkinsona changed the title Property logging.threshold.console is easy to misconfigure in yaml Make it harder to misconfigure logging.threshold.console in yaml Apr 5, 2024
@mhalbritter mhalbritter self-assigned this Apr 5, 2024
@mhalbritter mhalbritter modified the milestones: 3.3.x, 3.3.0-RC1 Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants