How to use the addLayout function from log4js

Find comprehensive JavaScript log4js.addLayout code examples handpicked from public code repositorys.

30
31
32
33
34
35
36
37
38
39

let backupCount = 15;
if (hasAttr(mo.config.logger, 'backupCount') && hasAttr(mo.config.logger.backupCount, 'max')) {
    backupCount = mo.config.logger.backupCount.max;
}
log4js.addLayout('baetyl', () => logEvent => {
    const asctime = moment(logEvent.startTime).format('YYYY-MM-DD HH:mm:ss');
    const name = logEvent.categoryName;
    const levelname = logEvent.level.levelStr;
    const message = logEvent.data;
fork icon9
star icon7
watch icon10

-2
fork icon2
star icon15
watch icon4

+ 3 other calls in file

12
13
14
15
16
17
18
19
20
21

let tracePattern = 'yyyy-MM-dd-hh0000';
if (opts.hourly === false) tracePattern = 'yyyy-MM-dd';

const layout = { type: 'pretty' };
log4js.addLayout('pretty', () => formatLog4JS);
log4js.configure({
  levels: {
    SILLY: { value: 2500, colour: 'blue' }
  },
fork icon0
star icon0
watch icon0

41
42
43
44
45
46
47
48
49
50

    return JSON.stringify(log);
}

static setLogger(name, level) {
    addLayout('json', () => {
        return Logger.layout;
    });
    configure({
        appenders: {
fork icon0
star icon0
watch icon4

+ 3 other calls in file