How to use the configure function from log4js

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

37
38
39
40
41
42
43
44
45
46
    const name = logEvent.categoryName;
    const levelname = logEvent.level.levelStr;
    const message = logEvent.data;
    return `${asctime} - ${name} - ${levelname} - ${message}`;
});
log4js.configure({
    appenders: {
        file: {
            type: 'file',
            filename: mo.config.logger.path,
fork icon9
star icon7
watch icon10

18
19
20
21
22
23
24
25
26
27
    }
    else
        ;// built-in layout
}
try{
    log4js.configure(configuration);
}
catch(err){
    console.log('Error: ' + err.message);
}
fork icon2
star icon15
watch icon4

-2
fork icon2
star icon9
watch icon0

+ 3 other calls in file

46
47
48
49
50
51
52
53
54
55
56
57
  'credentialsFilename',
  'settingsFilename',
];


// This is a function to make it easy to create a new instance. It is important to not reuse a
// config object after passing it to log4js.configure() because that method mutates the object. :(
const defaultLogConfig = () => ({appenders: [{type: 'console'}]});
const defaultLogLevel = 'INFO';


const initLogging = (logLevel, config) => {
fork icon0
star icon0
watch icon1

+ 14 other calls in file

44
45
46
47
48
49
50
51
52
53

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

+ 3 other calls in file

149
150
151
152
153
154
155
156
157
158
    if (filename && config && config.reloadSecs) {
        initReloadConfiguration(filename, config.reloadSecs);
    }

    // config object could not turn on the auto reload configure file in log4js
    log4js.configure(config, opts);
};

function replaceProperties(configObj, opts) {
    if (configObj instanceof Array) {
fork icon0
star icon0
watch icon2