id0Sch / log4js-json-layout

provides a slim and easy to use json-layout for log4js-node
MIT License
17 stars 8 forks source link

Add appName config option #3

Closed ironyman closed 7 years ago

ironyman commented 7 years ago

We have multiple applications pushing logs to one log server and we'd like to differentiate between them in ElasticSearch queries.

id0Sch commented 7 years ago

Hi, Thanks for taking the time to contribute to this project! since now we will have both source & appName - it got me thinking maybe we need something more dynamic, maybe a new config object that will get merged into the output, WDYT?

ironyman commented 7 years ago

Sure, so it would be used like this

log4js.configure({
  appenders: {
    out: {
      type: 'console', layout: {
        type: 'json',
        static: {
          appName: 'testapp',
          source: 'development'
        }
      }
    }
  },
  categories: { default: { appenders: ['out'], level: 'info' } }
});
id0Sch commented 7 years ago

Yeah exactly, so if it's provided we simple merge it onto the object.

On Sun, Aug 27, 2017 at 18:27 ironyman notifications@github.com wrote:

Sure, so it would be used like this

log4js.configure({ appenders: { out: { type: 'console', layout: { type: 'json', static: { appName: 'testapp', source: 'development' } } } }, categories: { default: { appenders: ['out'], level: 'info' } } });

— You are receiving this because you were assigned.

Reply to this email directly, view it on GitHub https://github.com/id0Sch/log4js-json-layout/pull/3#issuecomment-325205238, or mute the thread https://github.com/notifications/unsubscribe-auth/AFl9RLBZ8ULxZLYxUBF_SVMFq2pfwqAxks5scYrVgaJpZM4PBmmV .

ironyman commented 7 years ago

Great, I've already pushed the change (in case you didn't notice).

id0Sch commented 7 years ago

looks great, do you mind updating the README + add test case?

ironyman commented 7 years ago

I left the mentions of source option in the README. What do you think?

id0Sch commented 7 years ago

it will be used only for backwards compatibility, i think it's fine.

id0Sch commented 7 years ago

@ironyman published, it's available in version 2.1.0 thanks for you time! much appreciated 👏

ironyman commented 7 years ago

Thank you.