ww24 / log4js-node-extend

log4js + line number
Apache License 2.0
28 stars 9 forks source link

How to configuring preffix or suffix of log? #10

Open hemavidal opened 7 years ago

hemavidal commented 7 years ago

There is a way to configure where the extended text will be placed in log message?

This:

log4js_extend(log4js, {
  path: __dirname,
  format: "at @name (@file:@line:@column)"
})
log4js.configure({
    appenders: { index: { type: 'file', filename: logpath, maxLogSize: 20480, backups: 10 }, out: { type: 'stdout' } },
    categories: { default: { appenders: ['index', 'out'], level: 'info' } }
})
const logger = log4js.getLogger('index')
logger.info('my info message')

Results in:

[2017-09-22 13:58:31.517] [INFO] index - my info message at methodName (index.js:24:10) And i want to modify to this: [2017-09-22 13:58:31.517] [INFO] index [methodName (index.js:24:10)] - my info message There is a way to do it?

ww24 commented 7 years ago

Sorry, it only support appending to tail of the log. https://github.com/ww24/log4js-node-extend/blob/v0.2.1/log4js-extend.js#L11