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

Enable specifying a style whenever using "%[" in a pattern #1344

Open
Mumeii opened this issue Nov 11, 2022 · 0 comments
Open

Enable specifying a style whenever using "%[" in a pattern #1344

Mumeii opened this issue Nov 11, 2022 · 0 comments

Comments

@Mumeii
Copy link
Contributor

Mumeii commented Nov 11, 2022

Hi

PatternLayout enable the usage of %[ field. It apply a color theme to subsequent logged text based on the log level

It's nice, but would it be possible to explicitly specify the required color ?

For example, using something like %[{yellow}

It would enable having a stable color scheme for certain parts of the logged lines, such as in %[{yellow}%c%] where the category would always be displayed in yellow, making it extra easy to spot.

I personally prefer having :

  • only the displayed log level part of my logs having a dynamic color theme, based on log level
  • certain key parts of the logged informations applied a static color theme
  • other part applied a default color theme

With the current version of log4js I'm using (v6.7.0), I can't achieve the second point.

The best I can do so far is something like this :
%]%r %[%p%] %c %m

With the currently proposed enhancement, it would be possible to write :
%[{blue}%r %[%p %[{yellow}%c %]%m

which, FMPOV, would make logs reading much easier

@Mumeii Mumeii changed the title Enable specifying the color whenever using %[ filed in a patter Enable specifying the color whenever using %[ filed in a pattern Nov 11, 2022
@Mumeii Mumeii changed the title Enable specifying the color whenever using %[ filed in a pattern Enable specifying the color whenever using "%[" in a pattern Nov 11, 2022
@Mumeii Mumeii changed the title Enable specifying the color whenever using "%[" in a pattern Enable specifying a style whenever using "%[" in a pattern Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant