Node.js logger with customizable appenders and rich output layout patterns


A simple logging library yet with powerful functionalities. Customizable appenders and rich output format. Share configurations through application.


npm i reflect-metadata @t2ee/core @t2ee/sl4js -S


Basic Example

  default: ConsoleDebug
  level: LogLevel.DEBUG
  - name: ConsoleDebug
    appender: console
      pattern: '%d{YYYY-MM-DD HH:mm:ss.SSS} %-7c{[%l]} %10n %5p - %2w  %m'
      level: LogLevel.DEBUG
  - name: FileLog
    appender: file
    pattern: '%d{YYYY-MM-DD HH:mm:ss.SSS} [%l] %10n %5p - %2w  %m'
    level: LogLevel.INFO
    file: relative(file.log)
LogManager.getLogger().debug('Hello World');

Custom Appender

interface Configuration extends AppenderConfiguration {


class ConsoleAppender extends Appender<Configuration> {
    public log(layout: Layout): void {
        let message: string = this.patternLayout.parse(layout);


Pattern refers to what you put in appenders’ pattern field, e.g, '%d{YYYY-MM-DD HH:mm:ss.SSS} %-7c{[%l]} %10n %5p - %2w %m'

As you can see in the example, any prefix digit, e.g, %7d, %-7d, refers to padding, positive means left, vice versa.

As for chacaters(placeholders) supported, see chart below.

character usage description
d %d, or %d{FORMAT}, FORMAT is a valid (momentjs)[//momentjs.com/] format it displays the date.
c %c{PATTERN}, PATTERN is any other valid pattern composite, it allows to pad multiple patterns all together.
n %n appender name
m %m message
p %p process id
w %w worker id
l %l level