log4rs
log4rs copied to clipboard
Allow use of hardcoded text styles in pattern encoder
The only formatter that the pattern encoder supports which affects text style is highlight
, which colors based on the log level. It should be possible to also set the text style to some specific configuration, but I'm not sure what syntax would make sense here, particularly in a way that would allow for full configuration of text color, background color, and text intensity.
Right now the dark blue color (info level) is really hard to read on a black background.
It would be great if the defaults were improved for legibility, or if the colors could be made configurable.
Your terminal controls what the colors look like: https://en.wikipedia.org/wiki/ANSI_escape_code#Colors
Yes, but dark blue is pretty dark on most systems. Cyan as a default might be easier to read. Or a blueish color in 256-color mode.
Ah, gotcha. I pulled the color selection from https://logback.qos.ch/manual/layouts.html#coloring but don't feel particularly strongly about the specifics.
Does anyone still care about this? I'm going to close if not.
I recently moved to this crate due to the support of both console and file logging and I can confirm that the blue color is really unreadable on my term as well with default color settings, so i don't believe this matter should be closed.
The colors should either be updated with the same as env_logger (I was previously using that crate) or they should have the ability to be configurable. So far I didn't found any functionality how can I configure the colors from the builder.
Colour (!) me interested in this too - like @Dango-rs, I'm moving from another log framework which exposed this feature and this would be nice to have. If there's interest in taking it, I could look at putting together a PR to implement it?
I'm thinking I'd want to look at adding some sort of mapping from level to colour in PatternEncoder as a first step, then expose that as a configuration item. It feels like it would be too much to try to shoehorn into the pattern itself though, so (using the example YAML config) I'd do something like this:
# An appender named "stdout" that writes to stdout
stdout:
kind: console
encoder:
pattern: "{d} {h({l})} {m}{n}"
level_colors:
INFO: Green
WARN: Yellow
ERROR: Red
Then go from those strings to Color values, using no colour where there's no match (so, for example, if I do TRACE: DeepPurple, that gets ignored).
Does that all seem reasonable?
consider add support for level color, just like this: ColoredLevelConfig