trentm / node-bunyan

a simple and fast JSON logging module for node.js services
Other
7.16k stars 515 forks source link

Customize the message field name #313

Open mickaeltr opened 8 years ago

mickaeltr commented 8 years ago

My application logs are sent to a SaaS that requires a message field (instead of msg). Is there any way to customize this? Thanks

susomartinez commented 8 years ago

+1

ygrenzinger commented 8 years ago

Same question. I would love to customize the output having msg to message mainly and maybe removing some "standard" field.

trentm commented 8 years ago

Thanks for the question and sorry for the delays. I'll be making a second pass through the issues to actually triage. Before then a note to myself: I vaguely recall an earlier question where I posed a custom bunyan stream that could effectively do this. TODO: find that again.

oryagel commented 7 years ago

Sorry to bump this. I have the same issue of a SaaS that expect a message field instead of msg. Is this possible somehow?

Thanks

viniciusgama commented 6 years ago

same here. Anyone managed to solve this?

jbunton-atlassian commented 6 years ago

You could try pino

gkrinc commented 5 years ago

I would love to see a way for all standard fields to be modified. Our log levels follow RFC 3164 so it's kind of annoying that we can't change those in bunyan. And like OP our logging system expects message not msg and those extra fields create a lot of noise in our logging system.

Would be nice if this could either be done in a stream or serializer, where the final log object could be cloned and modified right before output.

SebTVisage commented 1 year ago

Any news on this?

ojizero commented 1 year ago

a possible workaround for this is to override the stream option when instantiating the logger, example

import * as Bunyan from 'bunyan';

const logger = Bunyan.createLogger({
  name: 'app logger',
  stream: {
    write: (log) => {
      const logObject = JSON.parse(log);
      logObject.message = logObject.msg;
      logObject.msg = undefined;
      return process.stdout.write(JSON.stringify(logObject) + '\n');
    },
  },
});

this may or may not feasible depending on the specific use-case!

image
SebTVisage commented 1 year ago

Personally, I went for pino instead. This project seems to be dead for 3 years, I don't know why so many projects go for it