Use color escape codes in format strings
mainYou can inject colors into your format strings using specific tokens:
Level-based tokens
log_color: Returns the color associated with the current log record's level.<name>_log_color: Returns a secondary color based on the log level (requiressecondary_log_colorsconfiguration).
Formatting tokens
{color},fg_{color},bg_{color}: Foreground and background colors.bold,bold_{color},fg_bold_{color},bg_bold_{color}: Bold/bright colors.thin,thin_{color},fg_thin_{color}: Thin colors (terminal dependent).reset: Clears all formatting.
Available color names
- Standard:
black,red,green,yellow,blue,purple,cyan,white. - Bright:
light_black,light_red,light_green,light_yellow,light_blue,light_purple,light_cyan,light_white. - 256-color: Use integers 0-255 (e.g.,
fg_196,bg_42).