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

logging.include-application-name has no effect when using log4j2 #38618

Closed
duoduobingbing opened this issue Dec 1, 2023 · 10 comments
Closed
Assignees
Labels
status: superseded An issue that has been superseded by another

Comments

@duoduobingbing
Copy link

As the title says, when creating a fresh Spring Boot 3.2.0 project the console logs generated by Logback look like this by default

2023-12-01T08:57:37.478+01:00  INFO 22208 --- [           main] com.example.demo.DemoApplicationTests    : No active profile set, falling back to 1 default profile: "default"
2023-12-01T08:57:38.181+01:00  INFO 22208 --- [           main] com.example.demo.DemoApplicationTests    : Started DemoApplicationTests in 0.832 seconds (process running for 1.308)

After switching from Logback to Log4j2 the console logs look like this

2023-12-01T09:02:33.314+01:00  INFO 14764 --- ${sys:LOGGED_APPLICATION_NAME}[           main] c.e.d.DemoApplicationTests               : No active profile set, falling back to 1 default profile: "default"
2023-12-01T09:02:33.938+01:00  INFO 14764 --- ${sys:LOGGED_APPLICATION_NAME}[           main] c.e.d.DemoApplicationTests               : Started DemoApplicationTests in 0.814 seconds (process running for 1.415)

Setting the new logging.include-application-name property to false does not make the ${sys:LOGGED_APPLICATION_NAME} disappear from the logged console output.

Here is a small reproducer: demo-reproducer.zip that can be run with mvn spring-boot:run

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 1, 2023
@mhalbritter mhalbritter changed the title logging.include-application-name has no effect when using log4j2 with Spring Boot 3.2.0 logging.include-application-name has no effect when using log4j2 Dec 1, 2023
@mhalbritter
Copy link
Contributor

mhalbritter commented Dec 1, 2023

Thanks for the report and the reproducer. This looks like a bug.

@mhalbritter mhalbritter added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 1, 2023
@mhalbritter mhalbritter added this to the 3.2.x milestone Dec 1, 2023
@mhalbritter
Copy link
Contributor

When setting the spring.application.name=my-app, the log output looks sane, as [my-app] is included instead of that ugly placeholder.

@itsAkshayDubey
Copy link
Contributor

Hi @mhalbritter ,

I would appreciate it if you could assign this bug to me, allowing me to work on resolving it.

Thanks,
Akshay

@itsAkshayDubey
Copy link
Contributor

When setting the spring.application.name=my-app, the log output looks sane, as [my-app] is included instead of that ugly placeholder.

When logging.include-application-name is set to false, the ${sys:LOGGED_APPLICATION_NAME} placeholder appears in the logs, irrespective of whether the spring.application.name property is present or not. On the other hand, when logging.include-application-name is set to its default value of true, the ${sys:LOGGED_APPLICATION_NAME} placeholder is only present in the logs when the spring.application.name property is not set.

@ilies-bel
Copy link

Hello,

I'd like to correct this problem, my PR is ready, please tell me if I have the right to propose it.

Thanks

@crspereira

This comment was marked as resolved.

@philwebb

This comment was marked as resolved.

@philwebb
Copy link
Member

@ilies-bel A pull request would be most welcome, please submit it at your earliest convenience.

@ilies-bel
Copy link

Done,
I am new to this project, tell me if I forgot anything

@philwebb
Copy link
Member

Closing in favor of PR #38847. Thanks @ilies-bel!

@philwebb philwebb closed this as not planned Won't fix, can't repro, duplicate, stale Dec 19, 2023
@philwebb philwebb added status: superseded An issue that has been superseded by another and removed type: bug A general bug labels Dec 19, 2023
@philwebb philwebb removed this from the 3.2.x milestone Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: superseded An issue that has been superseded by another
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants