Skip to content

Add more styling support to the Logback and Log4j2 color converters#49285

Merged
wilkinsona merged 2 commits into
spring-projects:mainfrom
mayankvirole:feature/extend-clr-ansi-styles
Mar 12, 2026
Merged

Add more styling support to the Logback and Log4j2 color converters#49285
wilkinsona merged 2 commits into
spring-projects:mainfrom
mayankvirole:feature/extend-clr-ansi-styles

Conversation

@mayankvirole
Copy link
Copy Markdown
Contributor

  • Add REVERSE (ANSI code 7) to AnsiStyle enum ,
  • Expand ColorConverter ELEMENTS map to include all AnsiStyle values (bold, italic, underline, normal, faint, reverse) and all AnsiBackground colors with the bg_ prefix (bg_red, bg_bright_green, etc.)
  • Update tests for both logback and log4j2 converters

Closes #49262

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 22, 2026
@wilkinsona
Copy link
Copy Markdown
Member

Thanks for the PR, @mayankvirole, but this isn't quite what we're looking for. Phil described this in his comment on the issue:

we'll probably need updates to the converters so that multiple parameters can be passed to the converter. Currently you can only specify one, which gets converted into a single AnsiElement. I think we'll need to support several so that you can set forground/background/style in one hit. We'd then need to add more items to the ELEMENTS map to cover AnsiStyle, AnsiBackground and AnsiColor.

For example, it should be possible to produce output that's both red and underlined (\e[4;31mRed and underlined\e[0m).

Would you like to refine your proposal to support using style, background, and color in combination?

@mayankvirole
Copy link
Copy Markdown
Contributor Author

Yes , allow me some time to refactor the code

@mayankvirole mayankvirole force-pushed the feature/extend-clr-ansi-styles branch 3 times, most recently from 005528d to d30ebac Compare February 24, 2026 13:03
@mayankvirole
Copy link
Copy Markdown
Contributor Author

I have refined my approach , please review it at your convenience.

@wilkinsona
Copy link
Copy Markdown
Member

Thanks for the updates, @mayankvirole. I'd like to discuss this one with the rest of the team. With the support for styling (and not just foreground and background colours), the ColorConverter class names are no longer an ideal fit. Perhaps more importantly the clr keyword also doesn't fit quite so well. I'm wondering if we need to rename things or perhaps introduce the new capabilities in a new converter with a new keyword and deprecate the old.

@wilkinsona wilkinsona added the for: team-meeting An issue we'd like to discuss as a team to make progress label Mar 2, 2026
@wilkinsona
Copy link
Copy Markdown
Member

We discussed this today and we're going to stick with the Color… class names and clr keyword as the primary purpose is still to change the text colour with the styling being additions on top of that.

@wilkinsona wilkinsona removed the for: team-meeting An issue we'd like to discuss as a team to make progress label Mar 4, 2026
@mayankvirole
Copy link
Copy Markdown
Contributor Author

Sounds good, thanks for the update! Let me know if there's anything else you need me to change

@wilkinsona wilkinsona changed the title Add support for bold, italic, underline, reverse, and bg_* colors in … Add more styling support to the Logback and Log4j2 color converters Mar 11, 2026
wilkinsona pushed a commit to wilkinsona/spring-boot that referenced this pull request Mar 11, 2026
- Add REVERSE (ANSI code 7) to AnsiStyle enum
- Expand ColorConverter ELEMENTS map to include all AnsiStyle values
  (bold, italic, underline, normal, faint, reverse) and all AnsiBackground
  colors with the bg_ prefix (bg_red, bg_bright_green, etc.)
- Update tests for both logback and log4j2 converters

See spring-projectsgh-49285

Signed-off-by: mvirole <virolemayank@gmail.com>
wilkinsona added a commit to wilkinsona/spring-boot that referenced this pull request Mar 11, 2026
mayankvirole and others added 2 commits March 11, 2026 16:11
- Add REVERSE (ANSI code 7) to AnsiStyle enum
- Expand ColorConverter ELEMENTS map to include all AnsiStyle values
  (bold, italic, underline, normal, faint, reverse) and all AnsiBackground
  colors with the bg_ prefix (bg_red, bg_bright_green, etc.)
- Update tests for both logback and log4j2 converters

See spring-projectsgh-49285

Signed-off-by: mvirole <virolemayank@gmail.com>
@wilkinsona wilkinsona force-pushed the feature/extend-clr-ansi-styles branch from d30ebac to 29e4938 Compare March 12, 2026 09:29
@wilkinsona wilkinsona merged commit bf1b0f6 into spring-projects:main Mar 12, 2026
@wilkinsona wilkinsona added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 12, 2026
@wilkinsona wilkinsona added this to the 4.1.0-M3 milestone Mar 12, 2026
@wilkinsona
Copy link
Copy Markdown
Member

Thanks very much, @mayankvirole.

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

Successfully merging this pull request may close these issues.

Add more ansi styles to the logging system

3 participants