log4js-node
log4js-node copied to clipboard
util.format options need
options to config... Can't change depth now
@thegobot Would using JSON.stringify(myObject, null, 2) manually suffice?
Using your changes (hard-coded to depth=4)
const myObject = {"a":"a","b":{"c":"c","d":{"e":"e","f":{"g":"g","h":{"i":"i","j":{"k":"k"}}}}}};
const log4js = require("log4js");
const logger = log4js.getLogger();
logger.level = "debug";
logger.debug(myObject);
[2022-01-16T02:30:16.495] [DEBUG] default - {
a: 'a',
b: {
c: 'c',
d: { e: 'e', f: { g: 'g', h: { i: 'i', j: [Object] } } }
}
}
Using original code
const myObject = {"a":"a","b":{"c":"c","d":{"e":"e","f":{"g":"g","h":{"i":"i","j":{"k":"k"}}}}}};
const log4js = require("log4js");
const logger = log4js.getLogger();
logger.level = "debug";
logger.debug(myObject);
logger.debug(JSON.stringify(myObject, null, 2)); // manual
const util = require("util");
logger.debug(util.formatWithOptions({ depth: 5 }, myObject)); // manual
[2022-01-16T02:24:44.084] [DEBUG] default - { a: 'a', b: { c: 'c', d: { e: 'e', f: [Object] } } }
[2022-01-16T02:23:54.991] [DEBUG] default - {
"a": "a",
"b": {
"c": "c",
"d": {
"e": "e",
"f": {
"g": "g",
"h": {
"i": "i"
"j": {
"k": "k"
}
}
}
}
}
}
[2022-01-16T21:31:13.805] [DEBUG] default - {
a: 'a',
b: {
c: 'c',
d: {
e: 'e',
f: { g: 'g', h: { i: 'i', j: { k: 'k' } } }
}
}
}