1

I configured this layout:

log4js.configure({                              
  appenders: {                                  
        out     : {                             
                type :'stdout',
                layout: {
                    type: 'pattern',
                    pattern:"%d  %X{custom} %m %n",
            }
        }                                   
  },                                            
  categories: { default: { appenders: ['out'], level: 'debug' } }                    
});
const logger = log4js.getLogger("default");              
logger.level = 'debug';
logger.addContext("custom","EHI");
logger.debug("ciao");

But not custom variable is present in the logger:

[2018-07-11T17:31:31.572] [DEBUG] default - ciao
gdm
  • 7,647
  • 3
  • 41
  • 71

1 Answers1

0

I ran the exact same code with version 6.1.2 of log4js module and I got the following output:

2020-04-08T19:05:55.334  EHI ciao

I guess that's the output you were expecting at first. It may be a problem in the version you were running.