Allow configuration of colors for each level #90

vjpr opened this Issue Aug 18, 2012 · 6 comments



Done in Version 2.x

4 participants

vjpr commented Aug 18, 2012

  1. The config should allow levels to be associated with a color.
  2. These colors should then been accessible when creating a custom pattern.

Not sure best way to add colors to patterns though.


nomiddlename commented Aug 20, 2012

Sounds useful. The first part sounds reasonably easy, and should be part of the config for the console appender since that's the only part of log4js that knows about colours.

Not sure about adding it to pattern layout though if that's what you mean, since that can be used in non-terminal loggers where the colour codes mess things up.


dignifiedquire commented Nov 22, 2012

I think it would be very useful to have a color pattern layout where you can use colors in your pattern. This way there is also no mixup when using non terminal loggers.

@dignifiedquire dignifiedquire added a commit to dignifiedquire/log4js-node that referenced this issue Dec 2, 2012

@dignifiedquire dignifiedquire [feature] Add color option to pattern layout.
Based on #90 this implements the possibillity to add the color codes
according to the log level via %[ and %].

vjpr commented May 26, 2013

Workaround at the moment for the first part of the question is:

level = ->
  args = level.caller.arguments

log4js.configure appenders: [{pattern: '%[%x{level}%]', tokens: level: level}]


nomiddlename commented Mar 27, 2017

Duplicate of #254 - fix for that should fix this one.

nomiddlename added this to the 2.x milestone Mar 27, 2017

Great to find this issue report. Please consider provide individual colors for log levels and individual colors for categories.

nomiddlename moved from TODO to In progress in Version 2.x Jul 2, 2017

@nomiddlename nomiddlename pushed a commit that referenced this issue Jul 2, 2017

Gareth Jones feat(levels): custom colours for levels in config #90 #254 0d10e2a

nomiddlename moved from In progress to Done in Version 2.x Jul 2, 2017

nomiddlename moved from In progress to Done in Version 2.x Jul 8, 2017


nomiddlename commented Jul 8, 2017

Released in version 2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment